Allow to load plugins

This commit is contained in:
Luke Murphy 2021-01-16 20:37:25 +01:00
parent 866029256a
commit 2526ce330d
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
3 changed files with 17 additions and 0 deletions

View File

@ -5,6 +5,7 @@
- Allow to configure avatar from configuration file and environment
- Load Redis details fron conf and CLI also ([#23](https://git.autonomic.zone/decentral1se/xbotlib/issues/23))
- Migrate Redis environment naming: `REDIS_URL` -> `XBOT_REDIS_URL` ([#23](https://git.autonomic.zone/decentral1se/xbotlib/issues/23))
- Allow to load custom plugins ([#24](https://git.autonomic.zone/decentral1se/xbotlib/issues/24))
# xbotlib 0.10.0 (2021-01-16)

View File

@ -189,6 +189,16 @@ You should see `INFO Successfully connected to storage` when your bot
initialises. Please see the `GlossBot` example for more on how to work with
this type of storage.
## Loading Plugins
You can specify a `plugins = [...]` on your bot definition and they will be
automatically loaded.
```python
class MyBot(Bot):
plugins = ["xep_0066"]
```
## Roadmap
See the [issue tracker](https://git.autonomic.zone/decentral1se/xbotlib/issues).

View File

@ -361,6 +361,12 @@ class Bot(ClientXMPP):
self.register_plugin("xep_0199") # XMPP Ping
self.register_plugin("xep_0084") # User Avatar
try:
for plugin in self.plugins:
self.register_plugin(plugin)
except AttributeError:
self.log.info("No additional plugins loaded")
def init_db(self):
"""Initialise the Redis key/value store."""
if not self.redis_url: