chickadee » irc » irc:add-message-handler!

irc:add-message-handler! CONNECTION PROC #!key command sender receiver body tag codeprocedure

Defines a message handler for the given CONNECTION that will invoke the one argument procedure PROC with the received message object when all of the regular expressions given for the keyword arguments match (uses string-search), and the code, which should be an exact integer (and is compared using eq?).

The keyword tag defines a message-handler tag, which can be used to remove the handler at a later time.

Note that if this procedure is called with two arguments (and no keyword args), then the message handler will be invoked for all incoming messages.

Message handlers are run in the order in which they are defined. A message handler should return #f if further handlers should be invoked for the same message, or true if other handlers should not be called.

The command, sender, receiver and body arguments may optionally be predicates instead of strings (which will be called with the respective part of the checked message) to allow more fine-grained matching.