ready
This commit is contained in:
parent
21c7f71971
commit
edd44564d2
5 changed files with 42 additions and 10 deletions
30
README.md
Normal file
30
README.md
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
# LXMFBot
|
||||||
|
|
||||||
|
Python class to easily develop a simple Telethon style chatbot for the LXMF protocol.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```
|
||||||
|
$ pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
- Instantiate the class with a name for the bot as parameter
|
||||||
|
- Use the `received` decorator to define functions for parsing received messages
|
||||||
|
- Use the `send(recipient_hash, message)` or `reply(message)` methods to send messages
|
||||||
|
- Launch the bot using the `run` method
|
||||||
|
|
||||||
|
Example of a bot that echos a message back to the sender:
|
||||||
|
|
||||||
|
```Python
|
||||||
|
from bot import LXMFBot
|
||||||
|
|
||||||
|
bot = LXMFBot("NodeBot")
|
||||||
|
|
||||||
|
@bot.received
|
||||||
|
def echo_msg(msg):
|
||||||
|
msg.reply(msg.content)
|
||||||
|
|
||||||
|
bot.run()
|
||||||
|
```
|
||||||
9
example.py
Normal file
9
example.py
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
from lxmfbot import LXMFBot
|
||||||
|
|
||||||
|
bot = LXMFBot("NodeBot")
|
||||||
|
|
||||||
|
@bot.received
|
||||||
|
def echo_msg(msg):
|
||||||
|
msg.reply(msg.content)
|
||||||
|
|
||||||
|
bot.run()
|
||||||
10
randobot.py
10
randobot.py
|
|
@ -1,10 +0,0 @@
|
||||||
from bot import LXMFBot
|
|
||||||
from pprint import pprint
|
|
||||||
|
|
||||||
bot = LXMFBot("Randobot")
|
|
||||||
|
|
||||||
@bot.received
|
|
||||||
def echo_msg(msg):
|
|
||||||
msg.reply(msg.content)
|
|
||||||
|
|
||||||
bot.run()
|
|
||||||
3
requirements.txt
Normal file
3
requirements.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
appdirs==1.4.4
|
||||||
|
lxmf==0.3.1
|
||||||
|
rns==0.5.2
|
||||||
Loading…
Add table
Add a link
Reference in a new issue