csbot.events module¶
-
class
csbot.events.HybridEventRunner(get_handlers, loop=None)[source]¶ Bases:
objectA hybrid synchronous/asynchronous event runner.
get_handlers is called for each event passed to
post_event(), and should return an iterable of callables to handle that event, each of which will be called with the event object.Events are processed in the order they are received, with all handlers for an event being called before the handlers for the next event. If a handler returns an awaitable, it is added to a set of asynchronous tasks to wait on.
The future returned by
post_event()completes only when all events have been processed and all asynchronous tasks have completed.Parameters: - get_handlers – Get functions to call for an event
- loop – asyncio event loop to use (default: use current loop)
-
class
csbot.events.Event(bot, event_type, data=None)[source]¶ Bases:
dictIRC event information.
Events are dicts of event information, plus some attributes which are applicable for all events.
-
event_type= None¶ The name of the event.
-
datetime= None¶ The value of
datetime.datetime.now()when the event was triggered.
-
-
class
csbot.events.CommandEvent(bot, event_type, data=None)[source]¶ Bases:
csbot.events.Event-
classmethod
parse_command(event, prefix, nick)[source]¶ Attempt to create a
CommandEventfrom acore.message.privmsgevent.A command is signified by event[“message”] starting with the command prefix string followed by one or more non-space characters.
Returns None if event[‘message’] wasn’t recognised as being a command.
-
arguments()[source]¶ Parse self[“data”] into a list of arguments using
parse_arguments(). This might raise aValueErrorif the string cannot be parsed, e.g. if there are unmatched quotes.
-
classmethod