|
|||||||
![]() |
Forum Index > Jibble.org > PircBot | ||
antiflooding measures |
|||
| | | Printable Version |
|
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? |
![]() Newbie Status: offline
Registered: 01/01/10 |
||||||||
|
|||||||||
|
DeadEd | ||||||||
|
Hi, and Happy New Year Would the ThrottleBot PircBotDemo be of any help? |
![]() Moderator Status: offline
Registered: 06/01/04 |
||||||||
|
|||||||||
|
CyrusTheVirus | ||||||||
|
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. |
![]() Newbie Status: offline
Registered: 01/01/10 |
||||||||
|
|||||||||
|
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.
|
![]() Moderator Status: offline
Registered: 06/01/04 |
||||||||
|
|||||||||
|
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" } }
the above has had no noticable impact on bot performance and has been very effective at killing flood attempts.
|
![]() Newbie Status: offline
Registered: 03/05/09 |
||||||||
|
|||||||||
|
|
| All times are CDT. The time is now 10:42 AM. |
|
|