Add examples

This commit is contained in:
Luke Murphy 2021-01-10 15:05:44 +01:00
parent cc5ef29d2e
commit f6d9fbc39c
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
3 changed files with 37 additions and 1 deletions

1
.gitignore vendored
View File

@ -9,4 +9,3 @@ build/
dist/
pip-wheel-metadata/
bot.conf
echo.py

17
examples/echo.py Normal file
View File

@ -0,0 +1,17 @@
from xbotlib import Bot
class EchoBot(Bot):
"""SYN/ACK bot for testing things work.
Just direct message the bot and see if you get back what you sent. If so,
then you know your setup is working.
"""
def react(self, message):
"""Send back what we get."""
self.reply(to=message.sender, body=message.body)
EchoBot()

20
examples/whisper.py Normal file
View File

@ -0,0 +1,20 @@
from xbotlib import Bot
class WhisperBot(Bot):
"""Pseudo-anonymous whispering in group chats.
In order to activate this bot you can invite it to your group chat. Once
invited, you can directly message the bot outside of the group chat and
tell it you want it to whisper your message into the group chat. The bot
will then do this on your behalf and not reveal your identity. This is nice
when you want to communicate with the group somewhat anonymously.
"""
def react(self, message):
"""Receive direct messages and pass them to group chats."""
pass
WhisperBot()