PtokaX forum

Archive => Archived 5.1 boards => Conversion Requests => Topic started by: Kastor on 23 April, 2007, 21:02:47

Title: deflood
Post by: Kastor on 23 April, 2007, 21:02:47
this script can be traslate or is too much difficult ????   :P

thanks



--=====================================
-- Flood e spam ban
---------------------------------------
-- version: 1.2 (06.2.2003)
-- author: DirtyFinger
-- email: DirtyFinger@gmx.net
-- ICQ : 145873101
-- HomePage: http://mitglied.lycos.de/dirtyfinger01/
-- (Yes, i know i still suck as Web Designer)
--=====================================
-- This script automatically bans pm-spammers and mainchat-spammers.
--
-- This does not protect from spam, but at least the spammer can't come back (at least not with the same ip)
-- For the script to work you might have to change the PtokaX flood-protection values (chat limit in the 'Rules and bots' section)
-- The script bans by default after 20 pms are being sent within 10 seconds.
-- But if the hub disconnects BEFORE the script triggers, no banning is possible and the spammer can come back.
-- So choose some quite generous settings, e.g. the first line of the above spam contains about 400 characters.
-- For the script to trigger you have to allow the users to send 8000 characters per second so the script can trigger.
--
-- Don't worry, real flooders send much much more so you'll be fine.
--
-- Version Changes :
-- 1.2 : bans mainchat flooder too. I didn't implement it in previous versions because i thought ptokax dealt with it.
-- 1.1 : removed the mainchat flooding of ban notifications
-- 1.0 : first version

sBotName = "{AntiFlood}"

PMCount = {}
MainCount = {}
MaxPM = 20 -- more than 20 pms within 10 seconds cause a ban
MaxMain = 20 -- more than 20 mainchat msgs within 10 seconds cause a ban
timeslice = 10*1000 -- 10 seconds


function Main()
frmHub:RegBot(sBotName)
SendToAll(sBotName.." "..date(" launched at %B %d %Y %X "))
SetTimer(timeslice)
StartTimer()

end

--// This function is fired when a new data arrives
function DataArrival(curUser, sData)
if strfind(sData,"$To:") then
if PMCount[curUser.sIP] ~= nil then
PMCount[curUser.sIP] = PMCount[curUser.sIP] +1
--SendToAll("----",PMCount[curUser.sIP])
if PMCount[curUser.sIP] > MaxPM then
FloodDetected (curUser, sData)
PMCount[curUser.sIP] = -100
end
else
PMCount[curUser.sIP] = 1
end
elseif strfind(sData,curUser.sName,1,plain) == 2 then
if MainCount[curUser.sIP] ~= nil then
MainCount[curUser.sIP] = MainCount[curUser.sIP] +1
--SendToAll("----",PMCount[curUser.sIP])
if MainCount[curUser.sIP] > MaxMain then
FloodDetected (curUser, sData)
MainCount[curUser.sIP] = -100
end
else
MainCount[curUser.sIP] = 1
end
end

end

function OnTimer()
--for k,v in PMCount do
-- SendToAll("---------",k.."\t"..v)
--end
PMCount = {}
MainCount = {}
end

function FloodDetected (curUser,sData)
local message = " -= Spam Warning =-"
local name,ip = curUser.sName,curUser.sIP
SendToAll ("# "..sBotName.."-Alert #--> "..name .. " has been banned for spamming.")
message = message .."\r\n\t\t"
.. "Violation detected by: " .. name .."\r\n\t\t"
.. "IP: " .. ip .. "\t\r\n\t\t"
.. "Last packet : \t" .. sData

SendPmToOps (sBotName,message)
curUser:Ban()
curUser:Disconnect()
end
Title: Re: deflood
Post by: bastya_elvtars on 23 April, 2007, 21:15:27
This functionality is in PtokaX, no additional script is necessary.
Title: Re: deflood
Post by: Creative on 16 June, 2007, 06:58:46
Hello, i am using  PtokaX DC Hub 0.3.5.2.
I disabled everything in Options, but still users get disconnected if they paste big messages in PM.
Is there any bug in  PtokaX DC Hub 0.3.5.2???
Title: Re: deflood
Post by: Thor on 16 June, 2007, 09:39:30
Check the Deflood tab, instead of the Options tab ;) By the way, I think there were a problem with the private-message length limitation, which has been fixed in the newest version, so use that.
Title: Re: deflood
Post by: Creative on 16 June, 2007, 10:04:42
ohh sorry, it was Deflood tab only in which i had disabled all the options.....
Ya, i'll try using the new version... The new version is Ptokax0.3.6.0.7z right??
Title: Re: deflood
Post by: Thor on 16 June, 2007, 10:12:43
Yes, that's it. I suggest you to not to disable all deflood settings, rather than set it up correctly - try while it will work well.