Added some docstrings

This commit is contained in:
Felipe M 2020-12-11 21:36:51 +01:00
parent 3dcad9badf
commit 01debdd7d1
Signed by: fmartingr
GPG key ID: 716BC147715E716F

View file

@ -12,6 +12,12 @@ logger = structlog.get_logger(__name__)
class Plugin: class Plugin:
"""
Base Plugin class.
All attributes are required except for `requires_config`.
"""
id: str id: str
name: str name: str
help: str help: str
@ -19,12 +25,28 @@ class Plugin:
@abstractclassmethod @abstractclassmethod
def on_message(cls, message: Message, channel_config: Optional[Dict] = None): 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 pass
@lru_cache @lru_cache
def get_available_plugins(): def get_available_plugins():
"""Retrieves every available plugin""" """
Retrieves every available auto discovered plugin
"""
plugins = {} plugins = {}
for ep in pkg_resources.iter_entry_points("butterrobot.plugins"): for ep in pkg_resources.iter_entry_points("butterrobot.plugins"):
try: try: