This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot-2/plugins/reaction.lua
topkecleon 5c2591152e 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.
2015-08-23 02:10:37 -04:00

41 lines
885 B
Lua
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local triggers = {
['¯\\_(ツ)_/¯'] = '/shrug$',
['( ͡° ͜ʖ ͡°)'] = '/lenny$',
['(╯°□°)╯︵ ┻━┻'] = '/flip$',
[' o'] = '/homo$',
['ಠ_ಠ'] = '/look$'
}
local action = function(msg)
local message = string.lower(msg.text)
for k,v in pairs(triggers) do
if string.match(message, v) then
message = k
end
end
if msg.reply_to_message then
send_msg(msg.reply_to_message, message)
else
send_message(msg.chat.id, message)
end
end
-- 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
}