Telegram bot framework is a tool to facilitate the creation of new bots using python. The creation of new controllers is very similar to creating new controllers using ASP.NET.
In order to use it, clone the repo
git clone https://github.com/iceoffire/telegram_bot_framework.git
To be able to use it, you need a telegram bot key, if you don't have one already, I suggest that you read this doc.
With your telegram key, add it to the Environment Variable as TELEGRAM_BOT_KEY
and you are good to go.
In order to create a new command, you just need to add a new method inside any file with _controller in the path:
telegram_bot_framework/
Controllers
You just need to add a new function, like this:
def new_command(context):
# do something
pass
In this repository, we already have an example file, in the path:
telegram_bot_framework/
Controllers/
game_controller.py
In game_controller.py, we have 4 commands, we have:
- roll_dice
- Return a six-sided dice, or N sides if the user sends it in the context as an argument.
- random_pick
- Return a random option in the list of objects that the user sent through arguments (e.g. /random_pick option 1, option 2, option 3)
- should_i
- Return Yes/No to your question.
- russian_roulette
- Return the result of a match of Russian roulette.
Tool | Status |
---|---|
Controller | Ok |
Filter | Ok |
Logging | Ok |
Error handling | Ok |
Database | Wip |
Domain | Wip |
Repository | Wip |
Better examples | Wip |
requirements.txt | Wip |
Ulisses Gandini