diff --git a/miku/bot.lua b/miku/bot.lua index 0b20fc8..06beb2e 100644 --- a/miku/bot.lua +++ b/miku/bot.lua @@ -20,7 +20,7 @@ local bot = {} -bot.version = '160824' +bot.version = '160906' function bot:init(config) -- The function run when the bot is started or reloaded. assert(config.bot_api_key, 'Dein Bot-Token ist nicht in der Config gesetzt!') @@ -106,6 +106,22 @@ function bot:on_msg_receive(msg, config) -- The fn run whenever a message is rec full_fwd_name = '' end + if msg.reply_to_message then + if msg.reply_to_message.from.first_name then + from_name1 = msg.reply_to_message.from.first_name + else + from_name1 = '' + end + if msg.reply_to_message.from.last_name then + from_name2 = ' '..msg.reply_to_message.from.last_name + else + from_name2 = '' + end + full_from_name = '\27[3mAntwort auf \27[31m'..from_name1..from_name2..'\27[0m: ' + else + full_from_name = '' + end + if msg.text then user_msg = msg.text..'\27[0m' elseif msg.caption then @@ -136,7 +152,7 @@ function bot:on_msg_receive(msg, config) -- The fn run whenever a message is rec filetext = '' end - full_message = msg_time..from_chat..full_name..' \27[36m>>>\27[0m '..full_fwd_name..filetext..user_msg + full_message = msg_time..from_chat..full_name..' \27[36m>>>\27[0m '..full_fwd_name..full_from_name..filetext..user_msg print(full_message) if msg.date < os.time() - 5 then return end -- Do not process old messages.