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.
Parameters: |
|
---|
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.
Note
Rather than appending to this directly, you should use the addresponse() function.
The sender of the event, a dict with the following keys:
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.
Add a response to an event.
An event can contain more than one response, they’ll be sent as separate messages.
Parameters: |
|
---|
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):
event.addresponse(True)
# Sends something like u'user: Okay'
event.addresponse(False)
# Sends something like u"user: Shan't"
event.addresponse(u'Sure')
# 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'