2015-11-25 03:22:04 +01:00
|
|
|
-- Put this on the bottom of your plugin list, after help.lua.
|
2016-04-05 12:43:11 +02:00
|
|
|
-- If you want to configure your own greetings, copy the following table
|
|
|
|
-- (without the "config.") to your config.lua file.
|
|
|
|
|
2016-04-11 06:04:47 +02:00
|
|
|
local greetings = {}
|
|
|
|
|
2016-06-07 06:31:34 +02:00
|
|
|
local utilities = require('otouto.utilities')
|
2016-04-11 06:04:47 +02:00
|
|
|
|
2016-05-27 02:26:30 +02:00
|
|
|
function greetings:init(config)
|
|
|
|
config.greetings = config.greetings or {
|
|
|
|
['Hello, #NAME.'] = {
|
|
|
|
'hello',
|
|
|
|
'hey',
|
|
|
|
'sup',
|
|
|
|
'hi',
|
|
|
|
'good morning',
|
|
|
|
'good day',
|
|
|
|
'good afternoon',
|
|
|
|
'good evening'
|
|
|
|
},
|
|
|
|
['Goodbye, #NAME.'] = {
|
|
|
|
'bye',
|
|
|
|
'later',
|
|
|
|
'see ya',
|
|
|
|
'good night'
|
|
|
|
},
|
|
|
|
['Welcome back, #NAME.'] = {
|
|
|
|
'i\'m home',
|
|
|
|
'i\'m back'
|
|
|
|
},
|
|
|
|
['You\'re welcome, #NAME.'] = {
|
|
|
|
'thanks',
|
|
|
|
'thank you'
|
2016-04-05 12:43:11 +02:00
|
|
|
}
|
2016-05-27 02:26:30 +02:00
|
|
|
}
|
2016-04-11 06:04:47 +02:00
|
|
|
|
|
|
|
greetings.triggers = {
|
2016-04-26 06:45:05 +02:00
|
|
|
self.info.first_name:lower() .. '%p*$'
|
2016-04-05 12:43:11 +02:00
|
|
|
}
|
|
|
|
end
|
2015-11-25 03:22:04 +01:00
|
|
|
|
2016-05-27 02:26:30 +02:00
|
|
|
function greetings:action(msg, config)
|
2015-11-25 03:22:04 +01:00
|
|
|
|
2016-04-11 06:04:47 +02:00
|
|
|
local nick = self.database.users[msg.from.id_str].nickname or msg.from.first_name
|
2015-11-25 03:22:04 +01:00
|
|
|
|
2016-05-27 02:26:30 +02:00
|
|
|
for trigger,responses in pairs(config.greetings) do
|
2016-04-11 06:04:47 +02:00
|
|
|
for _,response in pairs(responses) do
|
2016-04-26 06:45:05 +02:00
|
|
|
if msg.text_lower:match(response..',? '..self.info.first_name:lower()) then
|
2016-05-29 19:08:39 +02:00
|
|
|
utilities.send_message(self, msg.chat.id, utilities.latcyr(trigger:gsub('#NAME', nick)))
|
2015-11-25 03:22:04 +01:00
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2016-04-11 06:04:47 +02:00
|
|
|
return greetings
|