From 01debdd7d1ec6b567157ee36413b20e91f18794e Mon Sep 17 00:00:00 2001 From: Felipe Martin Date: Fri, 11 Dec 2020 21:36:51 +0100 Subject: [PATCH] Added some docstrings --- butterrobot/plugins.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/butterrobot/plugins.py b/butterrobot/plugins.py index e3be1e6..c85ab1c 100644 --- a/butterrobot/plugins.py +++ b/butterrobot/plugins.py @@ -12,6 +12,12 @@ logger = structlog.get_logger(__name__) class Plugin: + """ + Base Plugin class. + + All attributes are required except for `requires_config`. + """ + id: str name: str help: str @@ -19,12 +25,28 @@ class Plugin: @abstractclassmethod def on_message(cls, message: Message, channel_config: Optional[Dict] = None): + """ + Function called for each message received on the chat. + + It should exit as soon as possible (usually checking for a keyword or something) + similar just at the start. + + If the plugin needs to be executed (keyword matches), keep it as fast as possible + as this currently blocks the execution of the rest of the plugins on the channel + until this does not finish. + TODO: Update this once we go proper async plugin/message integration + + In case something needs to be answered to the channel, you can `yield` a `Message` + instance and it will be relayed using the appropriate provider. + """ pass @lru_cache def get_available_plugins(): - """Retrieves every available plugin""" + """ + Retrieves every available auto discovered plugin + """ plugins = {} for ep in pkg_resources.iter_entry_points("butterrobot.plugins"): try: