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

38 lines
902 B
Lua
Raw Normal View History

-- 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.
if not database.blacklist then
database.blacklist = {}
end
local triggers = {
''
}
local action = function(msg)
if database.blacklist[msg.from.id_str] then return end
if not msg.text:match('^/blacklist') then return true end
if msg.from.id ~= config.admin then return end
local target = user_from_message(msg)
if target.err then
sendReply(msg, target.err)
return
end
if database.blacklist[tostring(target.id)] then
database.blacklist[tostring(target.id)] = nil
sendReply(msg, target.name .. ' has been removed from the blacklist.')
else
database.blacklist[tostring(target.id)] = true
sendReply(msg, target.name .. ' has been added to the blacklist.')
end
end
return {
action = action,
triggers = triggers
}