Users can now display a list of reactions.lua options using /reactions, a help message dynamically
generated at plugin load and streamlined into the reactions system.
This commit is contained in:
parent
fe95fef505
commit
5c2591152e
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user