event module

class event.Event(_type)[source]

Bases: object

Allows event type definition. The definition accepts a regex. Every event can be triggered by specific lines, messages, message_id or users. Eventually (see time_event branch for proof-of-concept implementation) time-sensitive events will be triggerable as well.

Each line received by the bot is passed to each module in the modules_list. If the module determines the line matches what the event cares about, the event calls each of its subscribers itself, which contains all the information the module needs to respond appropriately.

To use:
e = Event(“__my_type__”) e.define(“some_regex”) bot.register_event(e, calling_module)
define(definition=None, msg_definition=None, user_definition=None, message_id=None, mode=None, case_insensitive=False)[source]

Define ourself by general line (definition), msg_definition (what someone says in a channel or PM), user_definition (the user who said the thing), or message_id (like 376 for MOTD or 422 for no MOTD) Currently, an event is defined by only one type of definition. If one were to remove the returns after each self. set, an event could be defined and triggered by any of several definitions.

Args: definition: string. regex allowed. msg_definition: string. regex allowed. this is what someone would say in a channel. like “hello, pybot”. user_definition: string. the user that said the thing. like ‘hlmtre’ or ‘BoneKin’. message_id: the numerical ID of low-level IRC protocol stuff. 376, for example, tells clients ‘hey, this is the MOTD.’


Fills out the event object per line, and returns True or False if the line matches one of our definitions. Args: line: string. The entire incoming line.

Return: boolean; True or False.


Fills out the object with all necessary information, then notifies subscribers with itself (an event with all the line information parsed out) as an argument. Args: line: string


Append passed-in event to our list of subscribing modules.

Args: e: event.