Skip to content

NPodlozhniy/telebot-tutorial

Repository files navigation

telebot-tutorial

Deploy

The project is organized in such a way that it consistently improves from a simple echo bot working locally to a complex tool in the hands of a business team for daily monitoring of the required indicators.

Python application Build Status Heroku CI Status License: MIT

Contents

  1. Getting started
  2. Early versions
  3. See also

Getting started

The project @ZelfAlertBot is a telegram bot, which is part of the analytical infrastructure at ZELF and allows the startup team to monitor important business indicators on a daily basis.

How to get secrets

You just need to create a bot using the @BotFather interface, you need to give it a name and save the received token. This value must be set to an environment variable TOKEN. Also you need to specify SECRETNAME which is used as login password, you can choose any safe string you like.

How to run

It is enough to download the latest version of the repository to your local computer, set the TOKEN and SECRETNAME environment variables, and modify the stats function in dataloader.py file accordance with your goals, this function will not work by default.

⬆️Contents


Early versions

This is the following sandbox for exploring telebot

Your first telegram bot

To start the Your first telegram bot run the following commands:

$ pip install pytelegrambotapi
$ set TOKEN=<YOUR TOKEN>
$ python main.py

Browse the repository at this point in the history

⬆️Contents


Second telegram bot

Second telegram bot starts on the Heroku by default, but to run locally you should just add one line to the beginning of the code above and modify the launch command:

$ pip install flask
$ python main.py --local

Browse the repository at this point in the history

⬆️Contents


Third telegram bot

Is the first intelligent version of @ZelfAlertBot bot with simple authentication through a security question, which, for instance, can send statistics on the main metrics for yesterday. In order to run locally, you need to run a few more commands:

$ pip install gspread
$ pip install oauth2client
$ pip install df2gspread
$ set SECRETNAME=<YOUR NAME>

Browse the repository at this point in the history

⬆️Contents


See also

  1. PyTelegramBotAPI library source code
  2. How to add Heroku CI badge

⬆️Contents