DeadEd.com
IRC Bots, Java Game Query and Control Libraries, iPhone Apps, and More ...
Sign Up!
Login
Welcome to DeadEd.com
Tuesday, September 07 2010 @ 10:42 AM CDT

 Forum Index > Jibble.org > PircBot
 antiflooding measures
 |  Printable Version
By: CyrusTheVirus (offline) on Friday, January 01 2010 @ 10:43 AM CST (Read 496 times)  
CyrusTheVirus

I want my bot to stop users who flood, i've checked the users class and there seems to get nothing there that can get the time a user's message is sent. Is there any solution to this problem, or would it be easier just to make a timer per each user?


Forum Newbie
Newbie

Status: offline

Registered: 01/01/10
Posts: 2

Profile Email    
   
By: DeadEd (offline) on Saturday, January 02 2010 @ 01:47 PM CST  
DeadEd

Hi, and Happy New Year Big Grin

Would the ThrottleBot PircBotDemo be of any help?


Forum Moderator
Moderator

Status: offline

Registered: 06/01/04
Posts: 589

Profile Email Website  
   
By: CyrusTheVirus (offline) on Saturday, January 02 2010 @ 04:56 PM CST  
CyrusTheVirus

Quote by: DeadEd

Hi, and Happy New Year Big Grin

Would the ThrottleBot PircBotDemo be of any help?

Yes same to you. Anyways i did look at that bot, it didn't work too well though. The bot would just kick people out randomly, sometimes when they spoke 1 or 2 lines, and sometimes it didn't kick until they spoke 6-7. I don't if the timer class is based on threads, because if it is, that might be the problem.


Forum Newbie
Newbie

Status: offline

Registered: 01/01/10
Posts: 2

Profile Email    
   
By: DeadEd (offline) on Sunday, January 03 2010 @ 03:33 AM CST  
DeadEd

The timer uses the JDKs own Timer class ( java.sun.com/javase/6/docs/api/javax/swing/Timer.html ) .

 

When a user types !throttleme, that is adding them to a list of "blocked" users for a scheduled 3 seconds - at which point they are removed from the list and are allowed to type again.  So if they spam !throttleme, you will see that the first message is allowed but then subsequent messages are ignored until the timer kicks in and removes them from the list, so this demo is actually based upon a single time (not on spam quantity) which is then cleared after THROTTLE_TIME is reached.  It's not a very good algorithm but does work well enough to keep the bot usable enough to allow admins to deal with the abuse.  3 seconds may be too short for you, you could also reset the timer if they speak again while on the blocked list, increase the block timer, etc

 

This was just a demo to give an idea on one way to go about it - and this was for throttling (slowing them down), not preventing them from using it.

If you find something which works well for you, please do share it - I am sure there are many users here that would like better anti-flood mechanisms.

 


Forum Moderator
Moderator

Status: offline

Registered: 06/01/04
Posts: 589

Profile Email Website  
   
By: jkhouw (offline) on Thursday, February 18 2010 @ 09:07 AM CST  
jkhouw

I wrote my own little algorithm that seems to work pretty well: I wanted to control two things - the number of messages permitted per unit of time ( I use 5 msgs in 5 seconds for this), and the number of duplicate messages permitted in the past m messages (regardless of time elapsed- I use 5 duplicate messages in the past 30 messages.  Note the 30 message stack size is any  msg by any user in the channel, but the duplicates are by an individual user.)

 

logic is roughly as follows:

 

I added some configuration variables (my settings are channel specific so I can turn on/off/or change any flood parameter per channel but for this example i will simplify and assume they are global):

  floodMsgHistory: will control the size of the history ArrayList that I will back check for flood control

  floodMsgTime: sets the limit in milliseconds for flood control

  floodMsgLimit: sets the maximum number of messages permitted in floodMsgTime

  floodMsgDuplicateLimit: Sets the max number of duplicate messages permitted by a single user in last floodMsgHistory msgs

 

I created an class of messages with properties of String ircNick, String ircChannel, Long msgTime, and String message

I then created an ArrayList<messages> msgs

 

then my algorigthm does the following:

when a new msg comes in i pop it onto the arraylist setting ircNick=sender, msgTime=System.currentTimeMillis() etc

then if the arraylist is greater than my checked history limit (which i set to 30 messages), I msgs.remove(0)

 

then init a few variables: int duplicateMsgCount, and msgCount

then loop through the ArrayList msgs

{

if (sender.equalsIgnoreCase(msgs.get(i).ircNick && channel.equals msgs.get(i).ircChannel) {

if (currentTime-msgs.get(i).msgTime<floodMsgTime) {msgCount++;}

if(msgs.get(i).message.equalsIgnoreCase(message)){duplicateMsgCount++;}

if (msgCount>floodMsgLimit || duplicateMsgCount>floodMsgDuplicateLimit) { kick(channel, sender, "Stop Spamming"Wink;break;}

}

}

 

the above has had no noticable impact on bot performance and has been very effective at killing flood attempts.

 

 


Forum Newbie
Newbie

Status: offline

Registered: 03/05/09
Posts: 14

Profile Email    
   



 All times are CDT. The time is now 10:42 AM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to Post 
Filtered HTML Allowed 
Censored Content 

Google Links ...

My Account





Sign up as a New User
Lost your password?

What's New

Stories

No new stories

Comments last 2 days

No new comments

Files last 14 days

No new files
No new comments

Links last 2 weeks

No new links