Added some docstrings

This commit is contained in:
Felipe Martin 2020-12-11 21:36:51 +01:00
parent 3dcad9badf
commit 01debdd7d1
Signed by: fmartingr
GPG Key ID: 716BC147715E716F
1 changed files with 23 additions and 1 deletions

View File

@ -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: