ibid.event – Events

class ibid.event.Event(source, type)

Events are at the core of Ibid’s workings. Every join/part/message seen by a source is dispatched as an ibid.event.Event to all the plugins to process. Then responses are extracted from it and returned to the source.

  • source – The name of the source that this event relates to.
  • type

    The type of the event, a string of one of the following values:

    A normal message
    An action, the result of a /me or /describe
    An IRC notice
    A state change, such as join, part, online, offline

Event inherits from dict so properties can be get and set either as attributes or keys.


The source string specified at creation.


The type string specified at creation.


A list of responses that should be returned.


Rather than appending to this directly, you should use the addresponse() function.


The sender of the event, a dict with the following keys:

The user’s nickname, as should be used for addressing him/her.
The unique identifier for the user. I.e. jabber address or SILC user key hash. Used for opening a conversation with a user.
The unique identifier of connection that the user spoke on. Used for addressing the reply to the correct client.

A string, that if present says the Complain processor should return an error message to the sender.

If set to 'notauthed', the complaint will be about insufficient authorisation.

If set to 'exception', the complaint will be about the bot not feeling very well.


A boolean flag indicating that the event has been processed and other Processors don’t need to look at it.


A SQLAlchemy sqlalchemy.orm.session.Session that can be used by a plugin for making queries.

It will be automatically committed by the dispatcher, but you are free to commit in a plugin so you can log a successful commit.

addresponse(response, params={}, processed=True, **kwargs)

Add a response to an event.

An event can contain more than one response, they’ll be sent as separate messages.

  • response – The unicode response to add, can contain string substitutions, which will be provided by params.
  • params – Parameters to substitute into response. Can either be a single unicode string or a dict of named substitutions.
  • processed – Set processed True if True. Default: True.
  • source – The source name to direct this reply to. Default: source.
  • target – The user to direct this reply to. Default: sender['connection'].
  • address – Boolean flag indicating if the user should be addressed when delivering this reply. Default: True.
  • action – Boolean flag for whether the reply is a message or an action. Default: False.
  • notice – Boolean flag for whether the reply is a message or an notice. Default: False.

Most commonly addresponse() is called with a unicode parameter for response and either a single substitution in params or multiple, named substitutions. However, you can also pass a Boolean value as response in which case the bot will emit a generic positive or negative response.

Examples (in public IRC):

# Sends something like u'user: Okay'
# Sends something like u"user: Shan't"
# Sends u"user: Sure"
event.addresponse(u'Jo said "%s"', message)
# Sends u'user: Jo said "hello"' if message was u'hello'
event.addresponse(u'%(key)s is %(value)s', {
   'key': u'Spiny Norman',
   'value': u'a Hedgehog',
# Sends u'user: Spiny Norman is a Hedgehog'
event.addresponse(u'Look at me', address=False)
# Sends u'Look at me'
event.addresponse(u'dances', action=True)
# Is the equivalent of '/me dances'