60570e90f3
added example plugin with documentation added liberbot-compliant flood control see Liberbot Support for details on getting compliant added Kickass Torrent plugin various bugfixes all files seem to have been marked changed due to a shift in platform I will do a clean clone and testing to ensure there is no issue.
47 lines
925 B
Lua
Executable File
47 lines
925 B
Lua
Executable File
floodcontrol = {}
|
|
|
|
local triggers = {
|
|
'/floodcontrol'
|
|
}
|
|
|
|
local action = function(msg)
|
|
|
|
local input, output
|
|
|
|
if msg.from.id ~= 100547061 then -- Only acknowledge Liberbot.
|
|
if not config.admins[msg.from.id] then -- or an admin. :)
|
|
return
|
|
end
|
|
end
|
|
input = get_input(msg.text) -- Remove the first word from the input.
|
|
input = JSON.decode(input) -- Parse the JSON into a table.
|
|
if not input.groupid then return end -- If no group is specified, end.
|
|
|
|
if not input.duration then -- If no duration is specified, set it to 5min.
|
|
input.duration = 600
|
|
end
|
|
|
|
floodcontrol[input.groupid] = os.time() + input.duration
|
|
|
|
local s = input.groupid .. ' silenced for ' .. input.duration .. ' seconds.'
|
|
|
|
send_message(-34496439, s)
|
|
|
|
end
|
|
|
|
local cron = function()
|
|
|
|
for k,v in pairs(floodcontrol) do
|
|
if os.time() > v then
|
|
floodcontrol[k] = nil
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
return {
|
|
triggers = triggers,
|
|
action = action,
|
|
cron = cron
|
|
}
|