REST API based bot for Rocket.Chat
Install
pip install RocketChatAPIBot
Usage
Create new bot
import os
from RocketChatBot import RocketChatBot
botname = os.environ['BOTNAME']
botpassword = os.environ['BOTPASSWORD']
server_url = os.environ['BOT_URL']
bot = RocketChatBot(botname, botpassword, server_url)
Send message to channel
bot.send_message('starting bot...', channel_id='GENERAL')
Direct message handler
Gets triggered when sentence starts with the botname like '@botname echo hello'
def greet(msg, user, channel_id):
bot.send_message('hello @' + user, channel_id)
bot.add_dm_handler(['hey', 'hello', ], greet)
Receives a list of keywords to trigger the command and the method to execute. The method should receive as parameters always msg as the message, user and channel_id
Auto answer handler
Gets triggered with the mention of keywords. Only made to respond with simple text, no functions.
bot.add_auto_answer(['good news', 'i have good news', ], ['hell yeah!', 'tell me, tell me!', 'you are already good news ;)', ])
Direct answer handler
Gets triggered when sentence starts with the name of the bot and keywords are in the sentence like '@botname who are you?'
bot.add_direct_answer(['who are you?', 'what is your name?', ], ['I am botname', ])
Handle unknow commands
bot.unknow_command = ['I do not know what you want me to do...', 'I\'m almost sure I\'m not programmed to do that', 'I have no idea how to do that so here is a hug :hugging:']
Metadata
Release files for RocketChatAPIBot 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| RocketChatAPIBot-0.1.4-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Release files / RocketChatAPIBot-0.1.4-py2.py3-none-any.whl
| Download URL | RocketChatAPIBot-0.1.4-py2.py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
2452ecd169394353e7047e89d8fb11627517c98f066095238b6d344459f641da
|
|
BLAKE2b-256 checksum How to use checksums |
a23c0f019e47e82139b3be95bfb1cd256e7d1a8fb018fbd9e2a4cb345d91283c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.7
|