From 4bd0a72b5a3f2206e27155f00514dcaf19d980d8 Mon Sep 17 00:00:00 2001 From: topkecleon Date: Sun, 29 Nov 2015 06:41:53 -0500 Subject: [PATCH] For photo messages, bot will look for commands in the caption if available. Fixed bug in chatter.lua where the bot will attempt to reply to photo messages. --- bot.lua | 2 +- plugins/chatter.lua | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bot.lua b/bot.lua index 2fbdc6d..7fa53b0 100755 --- a/bot.lua +++ b/bot.lua @@ -37,7 +37,7 @@ end on_msg_receive = function(msg) -- The fn run whenever a message is received. - if not msg.text then msg.text = '' end -- So about.lua works. + if not msg.text then msg.text = msg.caption or '' end -- So about.lua works. if msg.date < os.time() - 5 then return end -- Do not process old messages. msg.chat.id_str = tostring(msg.chat.id) diff --git a/plugins/chatter.lua b/plugins/chatter.lua index 5bd608d..c62b90f 100755 --- a/plugins/chatter.lua +++ b/plugins/chatter.lua @@ -8,6 +8,8 @@ local triggers = { local action = function(msg) + if msg.text == '' then return end + -- This is awkward, but if you have a better way, please share. if msg.text_lower:match('^' .. bot.first_name .. ',') then elseif msg.text_lower:match('^@' .. bot.username .. ',') then