REST API based bot for Rocket.Chat
Project description
# REST API based bot for [Rocket.Chat](http://rocket.chat)
## Install
`pip install RocketChatBot`
## Usage
### Create new bot
```python
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'
```python
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.
```python
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?'
```python
bot.add_direct_answer(['who are you?', 'what is your name?', ], ['I am botname', ])
```
### Handle unknow commands
```python
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:']
```
## Install
`pip install RocketChatBot`
## Usage
### Create new bot
```python
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'
```python
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.
```python
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?'
```python
bot.add_direct_answer(['who are you?', 'what is your name?', ], ['I am botname', ])
```
### Handle unknow commands
```python
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:']
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for RocketChatAPIBot-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6298461273f8728cf9096060840ca52544baae270e35a94eb3a1af814a43a5bb |
|
MD5 | 2ee32a63c3a26f7c24a9ff9de65e2eb8 |
|
BLAKE2b-256 | f93eb664b8f14ab022aadc91cb6caa40d7d19cf6c3fdea27bb2f29fa1d45d3a9 |