0

I have made my IRC bot and I've run into the problem of flooding. I'm trying to figure out a way to space out the messages so if 10 people all execute a command at the same time it doesn't excess flood the bot. How would I do this? I was thinking of implementing a Queue but I'm not sure where to go after that.

I'm not using any frameworks for this bot nor do I want to switch to any framework (unless its extremely easy).

1
  • I guess I should rephrase it then. I want to protect against flooding. Commented Dec 17, 2010 at 21:07

2 Answers 2

1

Sure, you could use a queue.

Let one thread put stuff on the queue, let another thread process items from the queue in a nice pace. It's an instance of the classical consumer / producer pattern.

Just make sure that you don't let your queue eat up all your memory in case of excessive flooding. (You could for instance just drop messages if the queue is full.)

Sign up to request clarification or add additional context in comments.

1 Comment

Well I'm going to be managing several adds to the queue at once. So lets say 10 people decide to run my !hello command which sends the channel "hello World!", I want to be able to manage that. Your example just delays it before every single command which is what I don't want. I want it to send the server "Hello World!" if people requesting < 5 or something along those lines.
0

java.util.concurrent probably has what you want. An Executor or just a BlockingQueue for example.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.