Other languages: русский, english
A telegram bot made in Python that will allow you to quickly deploy a convenient, multifunctional and extensible way to organize technical support for your product via Telegram.
Ways:
- Deploy using Docker (This way is recommended in case you are not going to change the source code)
- Deploy using the source code
Requirements: Docker (Installation: Windows, Linux), Git
First, let's clone this repo using next command:
git clone https://github.com/Kamilfo-Developer/telegram-support-bot.git
Then go to the repo root directory:
cd telegram-support-bot
Now we are ready to create .env
file which will be a config for the app. After it's done, we need to open it using a text editor. For example, nano for Linux or Notepad for Windows.
Since it's done, we have to set bot's configuration. If you launch the app via docker-compose (it's recommended if no additional options needed), simply add to the .env
file next lines:
BOT_TOKEN=<Your bot's token>
OWNER_PASSWORD=<Password for the owner initialization>
If you are curious about some of these fields, you can figure out their purpose here.
Next, you are going to need Docker. When it's installed, enter next command to the terminal:
docker-compose up -d
If you've done everything right, the bot will be ready to use. Congratulations!
Requirements: Python of version 3.10 or greater, Git
First, let's clone the repo:
git clone https://github.com/Kamilfo-Developer/telegram-support-bot.git
Then go to the repo root directory:
cd telegram-support-bot
Now we have to install poetry
:
- Windows:
pip install poetry
- Linux:
pip3 install poetry
That far, we are ready to install all the dependencies using poetry
(the installation speed can vary depending on your device's internet connection quality):
poetry install
Let's activate the environment with the collected dependencies:
poetry shell
Now we are ready to create .env
file which will be a config for the app. After it's done, we need to open it using a text editor. For example, nano for Linux or Notepad for Windows.
Since it's done, we have to set bot's configuration. If you are fine with SQLite as the Database, it's enough to add next lines to the .env
file:
BOT_TOKEN=<Your bot's token>
OWNER_PASSWORD=<Password for the owner initialization>
If you are curious about some of these fields, you can figure out their purpose here.
After completing the app's configuration, you have to apply migrations for the database using Alembic. To do so, enter next commands:
First, go to the migrations directory:
cd bot/db/migrations
Then apply the migrations:
alembic upgrade head
Finally, get back to the repo's root directory.
cd ../../..
If the migrations were applied successfully, you are ready to start the bot. Just use next command:
python -m bot
If you've done everything right, the bot will be ready to use. Congratulations!
Used for passing the token to the bot. The token can be obtained here: https://telegram.me/BotFather.
Default value: no default value
Password to for the owner initializing precess. Should be a single world. For example, MyReallyReliablePassword
.
After starting the bot, you will need to enter /initowner
command with the password as first argument. Eventually, you will have next string: /initowner MyReallyReliablePassword
. After sending this comnad, the bot will be ready to use.
Default value: no default value
Default owner's name. Must be a single word. For example, OwnerOfThisBot
.
Default value: Owner
Sets the default language. Will be used if user's language can't be found among the available languages. The string must be a IETF-tag. For example, ru
or en
.
Default value: en
.
Sets the database, which will be used as bot's storage.
Accepts next values: sqlite
, postgres
, mysql
Default value: sqlite
docker-compose default value: postgres
Timezone which will be used for formating date and time for users' messages. Example: America/New_York
. Full list of timezones in this format can be found here.
Default value: will be used local timezone
A name of corresponding asynchronous SQLAlchemy supported driver for PostgreSQL.
Keep in mind that for using not default driver, it must be installed first.
Default value: asyncpg
The name of database inside PostgreSQL.
Default value: postgres
The username inside PostgreSQL.
Default value: postgres
PostgreSQL database host.
Default value: localhost
docker-compose default value: db
PostgreSQL host's port.
Default value: 5432
PostgreSQL user's password.
Default value: postgres
A name of corresponding asynchronous SQLAlchemy supported driver for MySQL.
Keep in mind that for using not default driver, it must be installed first.
Default value: asyncmy
The name of database inside PostgreSQL. Must be set if you are using this database.
Default value: no default value
The username inside MySQL. Must be set if you are using this database.
Default value: no default value
MySQL database host.
Default value: localhost
MYSQL host's port.
Default value: 3306
MySQL user's password. Must be set if you are using this database.
Default value: no default value