| |
Methods defined here:
- __init__(self, bot)
- 1) set the bot attribute
2) load the stasher if any _stash_attrs are defined
3) initialize the settings (setting any defaults if empty)
4) set any _on_XXXX handlers with priority 0
- _del_handlers(self, priority=0, prefix='_on_')
- This "undoes" self._set_handlers
- _get_handlers(self, prefix)
- return a list of all event types for which it looks like
the module has handlers. If the module has defined _on_join and
_on_kick, then this will return ['join', 'kick']
if the attribute self._handlers is defined, it will be returned
instead
- _get_stasher(self, file=None, format=None, **kwargs)
- #_stash_file = 'foo.pickle' # will appear in the "data_dir"
- _set_handlers(self, priority=0, prefix='_on_')
- set handlers for all methods with prefix <prefix>
For example, if the method _on_join is defined, then that method
will be registered as handler for the "join" event.
If the attribute self._handlers is defined, it will be used instead.
each element of the self._handlers list should be the event type.
def _handle_join(self, conn, event): pass
def _handle_kick(self, conn, event): pass
def _handle_part(self, conn, event): pass
self._handlers = ['join', 'kick']
_set_handlers(prefix='_handle_')
In this case, only the first two will be set. If self._handlers
were not defined, then all three would be set.
- _stash(self, default=<class kibot.BaseModule.NoDefault>)
- Store the attributes listed in self._stash_attrs in a stasher.
One will be created if necessary. If a value isn't set and
a default is provided, that value will be used.
- _unload(self)
- 1) save the stasher if any _stash_attrs are defined
2) remove any _on_XXXX handlers
- _unstash(self, default=<class kibot.BaseModule.NoDefault>)
- Reload the attributes listed in self._stash_attrs from the
stasher. If the attribute was not in the stasher (or if the file
didn't exist) then the attribute will be set to 'default'. If
default is not provided, then the attribute will not be set at all.
Data and non-method functions defined here:
- __doc__ = 'This class is intended to provide a number of convenient and common\n features for kibot modules.'
- __module__ = 'kibot.BaseModule'
- _stash_attrs = []
- _stash_format = 'pickle'
|