From 566db41184d116bbfdf06e272836d24e61b835e1 Mon Sep 17 00:00:00 2001 From: dupie Date: Fri, 10 Jul 2015 20:46:51 -0400 Subject: [PATCH] combined shrug and lenny added flip, homo, shot added reply arguments to 8ball, slap, whoami aliased "/who" to whoami --- config.json | 3 +-- plugins/8ball.lua | 4 ++++ plugins/lenny.lua | 17 ----------------- plugins/reaction.lua | 27 +++++++++++++++++++++++++++ plugins/shrug.lua | 17 ----------------- plugins/slap.lua | 9 +++++++++ plugins/whoami.lua | 21 +++++++++++++-------- 7 files changed, 54 insertions(+), 44 deletions(-) delete mode 100644 plugins/lenny.lua create mode 100644 plugins/reaction.lua delete mode 100644 plugins/shrug.lua diff --git a/config.json b/config.json index 3b4f038..d95e0a6 100644 --- a/config.json +++ b/config.json @@ -26,13 +26,12 @@ "help.lua", "hex.lua", "imdb.lua", - "lenny.lua", "personality.lua", "pokedex.lua", "pun.lua", + "reaction.lua", "reddit.lua", "remind.lua", - "shrug.lua", "slap.lua", "time.lua", "urbandictionary.lua", diff --git a/plugins/8ball.lua b/plugins/8ball.lua index eaf20bc..b67e195 100644 --- a/plugins/8ball.lua +++ b/plugins/8ball.lua @@ -41,6 +41,10 @@ function PLUGIN.action(msg) math.randomseed(os.time()) + if msg.reply_to_message then + msg = msg.reply_to_message + end + if string.match(string.lower(msg.text), 'y/n') then message = PLUGIN.yesno[math.random(#PLUGIN.yesno)] else diff --git a/plugins/lenny.lua b/plugins/lenny.lua deleted file mode 100644 index 34ee8a1..0000000 --- a/plugins/lenny.lua +++ /dev/null @@ -1,17 +0,0 @@ -local PLUGIN = {} - -PLUGIN.triggers = { - '/lenny' -} - -function PLUGIN.action(msg) - - if msg.reply_to_message then - msg = msg.reply_to_message - end - - send_msg(msg, '( ͡° ͜ʖ ͡°)') - -end - -return PLUGIN diff --git a/plugins/reaction.lua b/plugins/reaction.lua new file mode 100644 index 0000000..36323f0 --- /dev/null +++ b/plugins/reaction.lua @@ -0,0 +1,27 @@ +local PLUGIN = {} + +PLUGIN.triggers = { + ['¯\\_(ツ)_/¯'] = '/shrug$', + ['( ͡° ͜ʖ ͡°)'] = '/lenny$', + ['(╯°□°)╯︵ ┻━┻'] = '/flip$', + ['┌(┌ ^o^)┐'] = '/homo$', + ['🔫'] = '/shot$' +} + +function PLUGIN.action(msg) + + local message = string.lower(msg.text) + + if msg.reply_to_message then + msg = msg.reply_to_message + end + + for k,v in pairs(PLUGIN.triggers) do + if string.match(message, v) then + return send_msg(msg, k) + end + end + +end + +return PLUGIN diff --git a/plugins/shrug.lua b/plugins/shrug.lua deleted file mode 100644 index 1f7e686..0000000 --- a/plugins/shrug.lua +++ /dev/null @@ -1,17 +0,0 @@ -local PLUGIN = {} - -PLUGIN.triggers = { - '/shrug' -} - -function PLUGIN.action(msg) - - if msg.reply_to_message then - msg = msg.reply_to_message - end - - send_msg(msg, '¯\\_(ツ)_/¯') - -end - -return PLUGIN diff --git a/plugins/slap.lua b/plugins/slap.lua index 6585a93..1b68325 100644 --- a/plugins/slap.lua +++ b/plugins/slap.lua @@ -100,6 +100,7 @@ function PLUGIN.action(msg) math.randomseed(os.time()) + local slapper local victim = get_input(msg.text) if victim then slapper = msg.from.first_name @@ -108,6 +109,14 @@ function PLUGIN.action(msg) slapper = bot.first_name end + if msg.reply_to_message then + victim = msg.reply_to_message.from.first_name + slapper = msg.from.first_name + if slapper == victim then + slapper = bot.first_name + end + end + local message = PLUGIN.getSlap(slapper, victim) send_message(msg.chat.id, latcyr(message)) diff --git a/plugins/whoami.lua b/plugins/whoami.lua index b955078..26912ab 100644 --- a/plugins/whoami.lua +++ b/plugins/whoami.lua @@ -1,17 +1,28 @@ local PLUGIN = {} PLUGIN.doc = [[ - /whoami - Get the user ID for yourself and the group. + /who + Get the user ID for yourself and the group. Use it in a reply to get info for the sender of the original message. ]] PLUGIN.triggers = { '^/whoami', '^/ping', + '^/who$' } function PLUGIN.action(msg) + if msg.from.id == msg.chat.id then + to_name = '@' .. bot.username .. ' (' .. bot.id .. ')' + else + to_name = string.gsub(msg.chat.title, '_', ' ') .. ' (' .. string.gsub(msg.chat.id, '-', '') .. ')' + end + + if msg.reply_to_message then + msg = msg.reply_to_message + end + local from_name = msg.from.first_name if msg.from.last_name then from_name = from_name .. ' ' .. msg.from.last_name @@ -21,12 +32,6 @@ function PLUGIN.action(msg) end from_name = from_name .. ' (' .. msg.from.id .. ')' - if msg.from.id == msg.chat.id then - to_name = '@' .. bot.username .. ' (' .. bot.id .. ')' - else - to_name = string.gsub(msg.chat.title, '_', ' ') .. ' (' .. string.gsub(msg.chat.id, '-', '') .. ')' - end - local message = 'You are ' .. from_name .. ' and you are messaging ' .. to_name .. '.' send_msg(msg, message)