https://github.com/obervinov/telegram-assistant
This project is a Telegram bot that helps with everyday tasks, such as keeping track of finances or achieving goals.
https://github.com/obervinov/telegram-assistant
assistant assistant-chat-bots finance finance-management finance-tracker financial-analysis goals goals-tracker reminder reminder-bot telegram telegram-bot telegram-bot-api
Last synced: 16 days ago
JSON representation
This project is a Telegram bot that helps with everyday tasks, such as keeping track of finances or achieving goals.
- Host: GitHub
- URL: https://github.com/obervinov/telegram-assistant
- Owner: obervinov
- License: mit
- Created: 2022-11-06T10:03:30.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-04-09T11:52:28.000Z (about 1 year ago)
- Last Synced: 2025-04-09T12:35:22.390Z (about 1 year ago)
- Topics: assistant, assistant-chat-bots, finance, finance-management, finance-tracker, financial-analysis, goals, goals-tracker, reminder, reminder-bot, telegram, telegram-bot, telegram-bot-api
- Language: Python
- Homepage:
- Size: 2.08 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Telegram-assistent






##
About this project
This bot helps to fix financial expenses on the basis of which it builds monthly reports.
Main functions:
- accounting of income and expenses
- generating monthly reports
The vault is used for:
- storage of sensitive configuration parameters
- storage of financial expenses and income
- storing user authorization events
##
Repository map
```sh
.
├── Dockerfile ### Manifest for building docker-image
├── LICENSE ### License info
├── README.md ### The file you're reading now
├── CHANGELOG.md ### All notable changes to this project will be documented in this file
├── bot.py ### Main file with code this project
├── docker-compose.yml ### Manifest for building and running project with all dependencies
├── requirements.txt ### List of python dependencies
└── doc ### Directory with content for documentation
├── bot-preview.gif # Gif animation with a demonstration of the work of bots
─── src ### Extended modules
├── finance.py # A code file containing a class and methods for processing the entered data and saving them to vault
└── messages.py # A code file containing a class and methods for generating beautiful messages with responses
2 directory, 9 files
```
##
Requirements
-
Vault server - [a storage of secrets for bot with kv v2 engine](https://developer.hashicorp.com/vault/docs/secrets/kv/kv-v2)
-
Telegram bot api token - [instructions for creating bot and getting a token of api](https://learn.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-telegram?view=azure-bot-service-4.0)
## Environment variables
| Variable | Description | Default |
| ------------- | ------------- | ------------- |
| `BOT_VAULT_APPROLE_ID` | [Approve-id created during vault setup](https://developer.hashicorp.com/vault/docs/auth/approle) | `not set` |
| `BOT_VAULT_APPROLE_SECRET_ID` | [Approve-secret-id created during vault setup](https://developer.hashicorp.com/vault/docs/auth/approle) | `not set` |
| `BOT_VAULT_ADDR` | The address at which the vault server will be available to the bot | `http://vault-server:8200` |
| `BOT_NAME` | The name of the bot | `telegram-assistent` |
| `BOT_VAULT_MOUNT_PATH` | The point of mounting secrets in the vault | `secretv2` |
##
How to run with docker-compose
1. Building and launching docker container with vault-server
```sh
docker-compose up -d vault-server
```
2. Configuration vault-server
```sh
# Go to the interactive shell of the vault container
docker exec -ti vault-server sh
# Init vault server
vault operator init
# Login in vault-server with root token
# ${VAULT_ROOT_TOKEN} - Root token for vault login. Substitute your own value instead of a variable. The root token was received in the output at the previous step
vault login ${VAULT_ROOT_TOKEN} -address=http://0.0.0.0:8200
# Enabling secret engine - kv version 2
vault secrets enable -version=2 -path=secretv2 kv
# Enabling auth with approle method
vault auth enable approle
### ${BOT_NAME} - your bot's name. Substitute your own value instead of a variable. For example: "telegram-assistent"
# Write policy rules to file in container
tee ${BOT_NAME}-policy.htl < How to run a bot locally without a docker
**You need an already running and configured vault to use the approle and kv v2 engine**
1. Installing python requirements
```sh
python3 -m pip install --upgrade pip
pip3 install -r requirements.txt
```
2. Uploading the bot configuration containing sensitive data to the vault
```sh
# ${TELEGRAM_API_TOKEN} - your bot's api token
# ${YOUR_TELEGRAM_ID} - telegram id of your account for authorization of messages sent by the bot (whitelist)
vault kv put secretv2/${BOT_NAME}-config/config b_token="${TELEGRAM_API_TOKEN}" whitelist="${YOUR_TELEGRAM_ID}"
```
3. Setting environment variables in the host OS (the required values must be obtained at the vault configuration step)
```sh
expot BOT_VAULT_APPROLE_ID="change_me"
expot BOT_VAULT_APPROLE_SECRET_ID="change_me"
```
4. Running bot
```sh
python3 bot.py
```
##
How to build a docker image with a bot
```sh
export BOT_VERSION=v1.0.0
export BOT_NAME="telegram-assistent"
docker build -t ghcr.io/${GITHUB_USERNAME}/${BOT_NAME}:${BOT_VERSION} . --build-arg BOT_NAME=${BOT_NAME}
docker push ghcr.io/${GITHUB_USERNAME}/${BOT_NAME}:${BOT_VERSION}
```