diff --git a/plugins/reaction.lua b/plugins/reaction.lua index 938fb43..2e8907f 100644 --- a/plugins/reaction.lua +++ b/plugins/reaction.lua @@ -1,6 +1,4 @@ -local PLUGIN = {} - -PLUGIN.triggers = { +local triggers = { ['¯\\_(ツ)_/¯'] = '/shrug$', ['( ͡° ͜ʖ ͡°)'] = '/lenny$', ['(╯°□°)╯︵ ┻━┻'] = '/flip$', @@ -8,11 +6,11 @@ PLUGIN.triggers = { ['ಠ_ಠ'] = '/look$' } -function PLUGIN.action(msg) +local action = function(msg) local message = string.lower(msg.text) - for k,v in pairs(PLUGIN.triggers) do + for k,v in pairs(triggers) do if string.match(message, v) then message = k end @@ -26,4 +24,17 @@ function PLUGIN.action(msg) end -return PLUGIN +-- The following block of code will generate a list of reactions add the trigger "/reactions" to display it. +-- Thanks to @Imandaneshi for the idea and early implementation. +local help = '' +for k,v in pairs(triggers) do + if v ~= '^/reactions?' then + help = help .. v:gsub('%$', ': ') .. k .. '\n' + end +end +triggers[help] = '^/reactions' + +return { + triggers = triggers, + action = action +}