2016-02-25 16:08:27 +01:00
|
|
|
-- Never change this plugin. It was not meant to be changed.
|
|
|
|
-- You may add reactions. You must never remove reactions.
|
|
|
|
-- You must never restructure. You must never disable this plugin.
|
2016-05-15 14:22:31 +02:00
|
|
|
-- - Drew, creator, a year later.
|
|
|
|
|
|
|
|
-- Nevermind, Brayden changed it.
|
|
|
|
-- - Drew, just now.
|
2016-02-25 16:08:27 +01:00
|
|
|
|
2016-04-11 06:04:47 +02:00
|
|
|
local reactions = {}
|
|
|
|
|
2016-06-07 06:31:34 +02:00
|
|
|
local utilities = require('otouto.utilities')
|
2016-04-11 06:04:47 +02:00
|
|
|
|
|
|
|
reactions.command = 'reactions'
|
2016-07-25 11:03:35 +02:00
|
|
|
reactions.doc = 'Returns a list of "reaction" emoticon commands.'
|
2016-04-11 06:04:47 +02:00
|
|
|
|
|
|
|
local help
|
|
|
|
|
2016-05-27 05:28:44 +02:00
|
|
|
function reactions:init(config)
|
2016-08-14 04:46:18 +02:00
|
|
|
-- Generate a "help" message triggered by "/reactions".
|
|
|
|
help = 'Reactions:\n'
|
|
|
|
reactions.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('reactions').table
|
|
|
|
local username = self.info.username:lower()
|
|
|
|
for trigger,reaction in pairs(config.reactions) do
|
|
|
|
help = help .. '• ' .. config.cmd_pat .. trigger .. ': ' .. reaction .. '\n'
|
|
|
|
table.insert(reactions.triggers, '^'..config.cmd_pat..trigger)
|
|
|
|
table.insert(reactions.triggers, '^'..config.cmd_pat..trigger..'@'..username)
|
|
|
|
table.insert(reactions.triggers, config.cmd_pat..trigger..'$')
|
|
|
|
table.insert(reactions.triggers, config.cmd_pat..trigger..'@'..username..'$')
|
|
|
|
table.insert(reactions.triggers, '\n'..config.cmd_pat..trigger)
|
|
|
|
table.insert(reactions.triggers, '\n'..config.cmd_pat..trigger..'@'..username)
|
|
|
|
table.insert(reactions.triggers, config.cmd_pat..trigger..'\n')
|
|
|
|
table.insert(reactions.triggers, config.cmd_pat..trigger..'@'..username..'\n')
|
|
|
|
end
|
2015-11-25 03:22:04 +01:00
|
|
|
end
|
|
|
|
|
2016-05-27 05:28:44 +02:00
|
|
|
function reactions:action(msg, config)
|
2016-08-14 04:46:18 +02:00
|
|
|
if string.match(msg.text_lower, config.cmd_pat..'reactions') then
|
|
|
|
utilities.send_message(self, msg.chat.id, help)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
for trigger,reaction in pairs(config.reactions) do
|
|
|
|
if string.match(msg.text_lower, config.cmd_pat..trigger) then
|
|
|
|
utilities.send_message(self, msg.chat.id, reaction)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
2015-11-25 03:22:04 +01:00
|
|
|
end
|
|
|
|
|
2016-04-11 06:04:47 +02:00
|
|
|
return reactions
|