Creating plugins docs WIP
This commit is contained in:
parent
7dd07394ed
commit
9874ad568d
2 changed files with 41 additions and 0 deletions
4
docs/README.md
Normal file
4
docs/README.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Butterrobot Documentation
|
||||
|
||||
## Index
|
||||
- [Creating a Plugin](./creating-a-plugin.md)
|
37
docs/creating-a-plugin.md
Normal file
37
docs/creating-a-plugin.md
Normal file
|
@ -0,0 +1,37 @@
|
|||
# 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,
|
||||
# ...
|
||||
)
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue