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/interactions.lua
topkecleon a1a4978a1b config, locale in lua
personality.lua -> interactions.lua
innumerable improvements
2015-07-15 02:15:23 -04:00

39 lines
872 B
Lua

-- config.people is a table of IDs/nicknames the bot can address more familiarly
-- like so:
-- 13227902: "Drew"
local PLUGIN = {}
PLUGIN.triggers = {
bot.first_name .. '%p?$',
'@' .. bot.username .. '%p?$',
'^tadaima%p?$',
'^i\'m home%p?$',
'^i\'m back%p?$'
}
function PLUGIN.action(msg)
local input = string.lower(msg.text)
if config.people[tostring(msg.from.id)] then msg.from.first_name = config.people[tostring(msg.from.id)] end
for i = 3, #PLUGIN.triggers do
if string.match(input, PLUGIN.triggers[i]) then
return send_message(msg.chat.id, 'Welcome back, ' .. msg.from.first_name .. '!')
end
end
for k,v in pairs(config.locale.interactions) do
for key,val in pairs(v) do
if input:match(val..',? '..bot.first_name) then
return send_message(msg.chat.id, k:gsub('#NAME', msg.from.first_name))
end
end
end
end
return PLUGIN