yagop / telegram-bot

UNMAINTAINED - A Telegram Bot based on plugins
GNU General Public License v2.0
848 stars 502 forks source link

ant flood #330

Closed drig0 closed 8 years ago

drig0 commented 8 years ago

tla that one pluguins kicking the members who make flood !!!!!!!!!!!!!!

siyanew commented 8 years ago

Look at this

do

local NUM_MSG_MAX = 5
local TIME_CHECK = 4 -- seconds

local function pre_process(msg)
  if msg.service then
    return msg
  end
    local hash = 'user:'..msg.from.id..':msgs'
    local msgs = tonumber(redis:get(hash) or 0)
    if msgs > NUM_MSG_MAX then
      print('User '..msg.from.id..'is flooding '..msgs)
    if msg.to.type=="chat" then
        local usermember = 'user#id'..msg.from.id
        local chatgroup = 'chat#id'..msg.to.id
        chat_del_user(chatgroup , usermember, ok_cb, false)
   end
   msg = nil
    end
    redis:setex(hash, TIME_CHECK, msgs+1)
  return msg
end

local function run(msg, matches)
return 
end

return {
  description = "Plugin to Check Flood on Group",
  usage = {
  },
  patterns = {
    "^!flood$",
    },
  run = run,
  pre_process = pre_process
}

end

You can change time and message check .

drig0 commented 8 years ago

thx bro I will look like is in the bot =)

drig0 commented 8 years ago

perfect bro very thanks =D =D =D

siyanew commented 8 years ago

your Welcome, if solved , close the issue please :smile: