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
topkecleon b5ea8f3bbe bunch of stuff
administration.lua: everything's better; automatic migration.
database.usernames -> database.users. View with /me.
Nicks and lastfm usernames moved to database.users; auto migrate.
2016-03-22 06:16:26 -04:00

38 lines
902 B
Lua
Executable File

-- 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
}