* Added base admin login/logout flows * Ignore local database * Channel model * Admin interface for channels and plugins * Added database tests along with workflows * Added some docstrings * Ignore .coverage file * Creating plugins docs WIP * Documentation * Black everything * Some documentation * Coverage for the plugins package as well * DB Fixes * Absolute FROM in Dockerfile * Database and logging fixes * Slack: Support private channels * Added pre-commit * black'd * Fixed UserQuery.create * Fixed ChannelPluginQuery.create exists call * Added ChannelPlugin menu for debugging * Ignore sqlite databases * Updated contributing docs
37 lines
677 B
Markdown
37 lines
677 B
Markdown
# Creating a Plugin
|
|
|
|
## Example
|
|
|
|
This simple "Marco Polo" plugin will answer _Polo_ to the user that say _Marco_:
|
|
|
|
``` python
|
|
# mypackage/plugins.py
|
|
from butterrobot.plugins import Plugin
|
|
from butterrobot.objects import Message
|
|
|
|
|
|
class PingPlugin(Plugin):
|
|
name = "Marco/Polo"
|
|
id = "test.marco"
|
|
|
|
@classmethod
|
|
def on_message(cls, message, **kwargs):
|
|
if message.text == "Marco":
|
|
yield Message(
|
|
chat=message.chat, reply_to=message.id, text=f"polo",
|
|
)
|
|
```
|
|
|
|
``` python
|
|
# setup.py
|
|
# ...
|
|
entrypoints = {
|
|
"test.marco" = "mypackage.plugins:MarcoPlugin"
|
|
}
|
|
|
|
setup(
|
|
# ...
|
|
entry_points=entrypoints,
|
|
# ...
|
|
)
|
|
```
|