Java IRC bot?

Associate
Joined
18 Mar 2007
Posts
291
Hi guys,

I'm currently writing an IRC bot in Java as a little challenge.

I've got simple things working, but what I want to do is create an anti-spam system. Anyone have any experience of this?

I'm not entirely sure where to start, my only thought has been to create some sort of table, storing the name of the sender and the time a message was sent then doing some calculations on that?? However, this could grow to be a massive table if in a large room.

Any thoughts?

Cheers.
 
Your method is probably about right, but use some kind of circular data structure for it as you only need to keep current time - n records to work out if someone is spamming, you will then have an upper bound of table size of n * people active in the room. If all you are storing for each entry is an int (which can be mapped to a nick) then you have an upperbound of 4 * n * NumberOfNicks bytes for your table, chances are you won't need n to be more than 5 (assuming one a second or so) and NumberOfNicks is likely to be less than 1 thousand which gives a lookup table of about 20kB - not the end of the world.

edit:
That was assuming all 1000 nicks had to be put in every entry, use some kind of collection for this and you'd probably find the table was generally much smaller.

reading through i really wasn't clear.

something like (in pseudocode)

Code:
int SECONDS_TO_COUNT = 5;
Vector<Integer>[] PeopleWhoSpoke = new Vector<Integer>[SECONDS_TO_COUNT];
for(int i = 0; i < SECONDS_TO_COUNT; i++)
  PeopleWhoSpoke[i] = new Vector<Integer>();
When someone speaks in a certain time frame then add them to the appropriate Vector, next timeframe increment your arrayindex and do the same, if your array index % SECONDS_TO_COUNT == 0, remove everything from the vector there and start over.
 
Last edited:
Back
Top Bottom