2015-11-25 03:22:04 +01:00
|
|
|
-- This plugin will allow the admin to blacklist users who will be unable to
|
|
|
|
-- use the bot. This plugin should be at the top of your plugin list in config.
|
2015-08-09 02:53:46 +02:00
|
|
|
|
2016-04-08 23:12:02 +02:00
|
|
|
local blacklist = {}
|
|
|
|
|
2016-06-07 06:31:34 +02:00
|
|
|
local utilities = require('otouto.utilities')
|
2016-04-08 23:12:02 +02:00
|
|
|
|
|
|
|
function blacklist:init()
|
|
|
|
if not self.database.blacklist then
|
|
|
|
self.database.blacklist = {}
|
|
|
|
end
|
2016-02-21 20:28:40 +01:00
|
|
|
end
|
|
|
|
|
2016-04-08 23:12:02 +02:00
|
|
|
blacklist.triggers = {
|
2015-11-25 03:22:04 +01:00
|
|
|
''
|
2015-08-09 02:53:46 +02:00
|
|
|
}
|
|
|
|
|
2016-05-27 02:26:30 +02:00
|
|
|
function blacklist:action(msg, config)
|
2015-08-09 02:53:46 +02:00
|
|
|
|
2016-04-08 23:12:02 +02:00
|
|
|
if self.database.blacklist[msg.from.id_str] then return end
|
|
|
|
if self.database.blacklist[msg.chat.id_str] then return end
|
2016-05-27 05:28:44 +02:00
|
|
|
if not msg.text:match('^'..config.cmd_pat..'blacklist') then return true end
|
2016-05-27 02:26:30 +02:00
|
|
|
if msg.from.id ~= config.admin then return end
|
2016-03-22 11:16:26 +01:00
|
|
|
|
2016-04-08 23:12:02 +02:00
|
|
|
local target = utilities.user_from_message(self, msg)
|
2016-03-22 11:16:26 +01:00
|
|
|
if target.err then
|
2016-05-29 19:08:39 +02:00
|
|
|
utilities.send_reply(self, msg, target.err)
|
2016-03-22 11:16:26 +01:00
|
|
|
return
|
2015-11-25 03:22:04 +01:00
|
|
|
end
|
|
|
|
|
2016-03-26 11:12:01 +01:00
|
|
|
if tonumber(target.id) < 0 then
|
|
|
|
target.name = 'Group'
|
|
|
|
end
|
|
|
|
|
2016-04-08 23:12:02 +02:00
|
|
|
if self.database.blacklist[tostring(target.id)] then
|
|
|
|
self.database.blacklist[tostring(target.id)] = nil
|
2016-05-29 19:08:39 +02:00
|
|
|
utilities.send_reply(self, msg, target.name .. ' has been removed from the blacklist.')
|
2015-08-09 02:53:46 +02:00
|
|
|
else
|
2016-04-08 23:12:02 +02:00
|
|
|
self.database.blacklist[tostring(target.id)] = true
|
2016-05-29 19:08:39 +02:00
|
|
|
utilities.send_reply(self, msg, target.name .. ' has been added to the blacklist.')
|
2015-08-09 02:53:46 +02:00
|
|
|
end
|
|
|
|
|
2015-11-25 03:22:04 +01:00
|
|
|
end
|
2015-08-09 02:53:46 +02:00
|
|
|
|
2016-04-08 23:12:02 +02:00
|
|
|
return blacklist
|