https://github.com/zefirka/bobot
Telegram Bot API wrapper for Python
https://github.com/zefirka/bobot
bot-api python telegram telegram-api telegram-bot
Last synced: 4 months ago
JSON representation
Telegram Bot API wrapper for Python
- Host: GitHub
- URL: https://github.com/zefirka/bobot
- Owner: zefirka
- License: mit
- Created: 2016-08-07T01:18:23.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-10-01T23:13:26.000Z (over 6 years ago)
- Last Synced: 2024-09-25T09:05:49.937Z (over 1 year ago)
- Topics: bot-api, python, telegram, telegram-api, telegram-bot
- Language: Python
- Homepage:
- Size: 515 KB
- Stars: 2
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# bobot [](https://travis-ci.org/zefirka/bobot)
# v0.1.5
Simple Telegram Bot API wrapper for Python
```
$ pip install bobot
```
## Usage
#### Initialize bot
```python
import bobot
# Create instance of bot
bot = bobot.init(TOKEN)
# setup telegram api webhook
bot.setWebhook(webHookUrl)
```
#### Subscribe on messages
```python
# by value of message text
bot.on('hello', 'hello yourself bro!') # set up request and response
# create message handlers
def sayHello(update):
message = update.get('message')
name = message.get('from').get('first_name')
text = message.get('text')
return '{0}, dear {1}'.format(text, name)
# create rule to handle update
rule = Rule({
'match': ['hello', 'aloha'],
'response': sayHello
})
# and assign that rule to bot
bot.rule(rule)
```
## Documentation
### [Bot API](https://github.com/zefirka/bobot/tree/master/docs/API.md)
### [Rules](https://github.com/zefirka/bobot/tree/master/docs/Rule.md)
### [Responses](https://github.com/zefirka/bobot/tree/master/docs/Responses.md)