Template of telegram chat bot based on the pyTelegramBotAPI module
This is a template for telegram chat bots which creates hierarchical menu from plain text file (menu.txt).
- Just edit the
menu.txt
file according to the rules described below in the Structure of themenu.txt
file Section in order to desribe your chatbot's multi-level menu. If your text file with a description of your chatbot's menu has another name (notmenu.txt
), you need to correctMENU_FN
variable inmain.py
. - Assign your telegram chatbot's token to
TOKEN
variable inmain.py
. The token you can obtain via BotFather bot.
Each menu item is separated by a line starting with '=' symbol.
The first line of each menu item must contain a hierarchical level of this menu item and a name of menu item. The name will be displayed as a button of chat bot menu (ReplyKeyboardMarkup, according to the official Telegram Bot API). The level must consist of digits and periods: 1. is a root level, 1.1 and 1.2 are sub-levels of root level 1., 1.2.1 is a sub-level of level 1.2, and so on.
The body of each menu item must be enclosed in curly brackets. This is a text which will be shown when this menu item is selected by user. The body may be multiple lines.
This script has been written using pyTelegramBotApi
module by eternnoir.