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/otouto/plugins/druasay.lua

41 lines
1.1 KiB
Lua
Raw Normal View History

2016-08-15 07:00:24 +02:00
--[[
This plugin causes the bot to respond to certain triggers over the owner's
account, via drua-tg.
It's basically the greetings plugin with drua instead of bot output.
It will also uppercase the output if the input is entirely uppercase.
]]
local drua = require('otouto.drua-tg')
local druasay = {}
function druasay:init(config)
druasay.triggers = {}
for _, triggers in pairs(config.druasay) do
for i = 1, #triggers do
table.insert(druasay.triggers, triggers[i])
end
end
druasay.error = false
end
function druasay:action(msg, config)
if msg.from.id == config.admin or msg.chat.type == 'private' then return end
for response, triggers in pairs(config.druasay) do
for _, trigger in ipairs(triggers) do
if msg.text_lower:match(trigger) then
local output
if msg.text == msg.text:upper() then
output = response:upper()
else
output = response
end
drua.message(msg.chat.id, output)
return
end
end
end
end
return druasay