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/antisquig.lua
topkecleon cacfea1fa5 otouto v3 is out!
Everything reworked and rewritten.
Antisquig is now a plugin to work with moderation.lua.
The bot can now upload photos, stickers, and other files.
Return values in plugin functions to affect the bot's behavior.
All this and more!
2015-11-24 21:22:04 -05:00

47 lines
1.1 KiB
Lua
Executable File

-- Put this at the very top of your plugin list, even before blacklist.lua.
antisquig = {}
local triggers = {
'[\216-\219][\128-\191]'
}
local action = function(msg)
local moddat = load_data('moderation.json')
if not moddat[msg.chat.id_str] then
return true
end
if moddat[msg.chat.id_str][msg.from.id_str] or config.moderation.admins[msg.from.id_str] then
return true
end
if antisquig[msg.from.id] == true then
return
end
antisquig[msg.from.id] = true
sendReply(msg, config.errors.antisquig)
sendMessage(config.moderation.admin_group, '/kick ' .. msg.from.id .. ' from ' .. math.abs(msg.chat.id))
sendMessage(config.moderation.admin_group, 'ANTISQUIG: ' .. msg.from.first_name .. ' kicked from ' .. msg.chat.title .. '.')
end
-- When a user is kicked for squigglies, his ID is added to this table.
-- That user will not be kicked again as long as his ID is in the table.
-- The table is emptied every five seconds.
-- Thus the bot will not spam the group or admin group when a user posts more than one infringing messages.
local cron = function()
antisquig = {}
end
return {
action = action,
triggers = triggers,
cron = cron
}