shellbot.updaters.base module¶
-
class
shellbot.updaters.base.
Updater
(engine=None, **kwargs)[source]¶ Bases:
object
Handles inbound events
Updaters are useful for logging or replication, or side storage, or achiving, of received events.
An event may be a Message, a Join or Leave notification, or any other Event.
Updaters expose a filtering function that can be connected to the inbound flow of events handled by the Listener.
Example:
updater = FileUpdater(path='/var/log/shellbot.log') listener = Listener(filter=updater.filter)
Here events are written down to a flat file, yet multiple updaters are available.
For example, push every event to Elasticsearch:
updater = ElasticsearchUpdater() listener = Listener(filter=updater.filter)
There is also an updater where events are written to a separate Cisco Spark room. This will be useful in cases where safety or control are specifically important.
We are looking for new updaters, so please have a careful look at this file and consider to submit your own module.
-
filter
(event)[source]¶ Filters events handled by listener
Parameters: event (Event or Message or Join or Leave, etc.) – an event received by listener Returns: a filtered event This function implements the actual auditing of incoming events.
-
format
(event)[source]¶ Prepares an outbound line
Parameters: event (Event or Message or Join or Leave) – an inbound event Returns: outbound line Return type: str This function adapts inbound events to the appropriate format. It turns an object with multiple attributes to a single string that can be saved in a log file.
-
on_bond
(bot)[source]¶ Reacts on space bonding
This function should be expanded in sub-class, where necessary.
Example:
def on_bond(self, bot): self.db = Driver.open(bot.id)
-
on_dispose
()[source]¶ Reacts on space disposal
This function should be expanded in sub-class, where necessary.
Example:
def on_disposal(self): self.db = Driver.close()
-