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/personality.lua

49 lines
1.1 KiB
Lua
Raw Normal View History

2015-07-08 04:24:12 +02:00
-- config.people is a table of IDs/nicknames the bot can address more familiarly
-- like so:
-- 13227902: "Drew"
2015-07-03 00:15:52 +02:00
local PLUGIN = {}
PLUGIN.triggers = {
2015-07-08 04:24:12 +02:00
bot.first_name .. '%p?$',
2015-07-03 00:15:52 +02:00
'^tadaima%p?$',
'^i\'m home%p?$',
'^i\'m back%p?$'
}
function PLUGIN.action(msg)
2015-07-03 00:15:52 +02:00
local input = string.lower(msg.text)
2015-07-08 04:24:12 +02:00
if config.people[tostring(msg.from.id)] then msg.from.first_name = config.people[tostring(msg.from.id)] end
2015-07-03 00:15:52 +02:00
for i = 2, #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
interactions = {
[locale.responses.hello] = locale.hello,
[locale.responses.goodbye] = locale.goodbye,
[locale.responses.thankyou] = locale.thankyou,
[locale.responses.love] = locale.love,
[locale.responses.hate] = locale.hate
}
for k,v in pairs(interactions) do
for key,val in pairs(v) do
if input:match(val..',? '..bot.first_name) then
return send_message(msg.chat.id, k..', '..msg.from.first_name..'!')
end
end
2015-07-03 00:15:52 +02:00
end
-- msg.text = '@' .. bot.username .. ', ' .. msg.text:gsub(bot.first_name, '')
-- on_msg_receive(msg)
2015-07-03 00:15:52 +02:00
end
return PLUGIN