https://github.com/obervinov/telegram-package
This module is designed to quickly initialize, authorize, and display various buttons/widgets for my telegram bots.
https://github.com/obervinov/telegram-package
module poetry poetry-python python-module python3 telebot telegram-bot
Last synced: 8 days ago
JSON representation
This module is designed to quickly initialize, authorize, and display various buttons/widgets for my telegram bots.
- Host: GitHub
- URL: https://github.com/obervinov/telegram-package
- Owner: obervinov
- License: mit
- Created: 2022-11-02T20:58:08.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-12-24T15:20:39.000Z (5 months ago)
- Last Synced: 2025-12-25T20:41:36.475Z (5 months ago)
- Topics: module, poetry, poetry-python, python-module, python3, telebot, telegram-bot
- Language: Python
- Homepage:
- Size: 392 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# Telegram Package
[](https://github.com/obervinov/telegram-package/actions/workflows/release.yaml)
[](https://github.com/obervinov/telegram-package/actions/workflows/github-code-scanning/codeql)
[](https://github.com/obervinov/telegram-package/actions/workflows/pr.yaml)





##
About this project
This is an additional implementation compared to the **telebot** module.
This module is designed for quick initialization, authorization, rendering various _buttons/widgets_ and sending stylized messages for telegram-bots.
##
Supported functions
- Creating a connection to the telegram api and initializing the objects necessary for the bot to function (_parser_, _format_, _types_, _etc_)
- Generating an inline keyboard button with a matrix of the specified size from the passed elements
- Starting the bot polling process
- Sending or editing a stylized message to a user
- Deleting a message from chat
- Interception of invoked exceptions
##
Data structure in Vault
The structure of storing the bot token in the **Vault**
Configuration path: `${mount_point}/configuration/telegram`
```json
{
"token": "1234567890:ABCDEFGHIJKLMNOPQRSTUVWXYZ"
}
```
The `policy` required by the module when interacting with **Vault**.
An example of a policy with all the necessary rights and a description can be found [here](tests/vault/policy.hcl).
##
Installing with Poetry
```bash
tee -a pyproject.toml < Usage example
### Environment variables
| Name | Description | Default value |
| ------------------- | ----------------- | ------ |
| `TELEGRAM_BOT_NAME` | Telegram bot name | `None` |
1. Create messages template file
```bash
tee -a configs/messages.json <{0}! {1}\nAccess for your account - allowed {2}",
"args": ["username", ":raised_hand:", ":unlocked:"]
}
}
}
```
- Simple usage
```python
# import module
from telegram import TelegramBot
# init class objects
telegram = TelegramBot(vault_client)
bot = telegram.telegram_bot
# decorator
@bot.message_handler(commands=['start'])
def start_message(message):
telegram.send_styled_message(
message.chat.id,
messages_template={
'alias': 'hello_message',
'kwargs': {
'username': message.from_user.first_name
}
}
)
# run bot pulling
telegram.launch_bot()
```
- With inline keyboard
```python
# import module
from telegram import TelegramBot
# init class objects
telegram_bot = TelegramBot(vault_client).telegram_bot
# decorator
@telegram_bot.message_handler(commands=['start'])
def start_message(message):
markup = telegram_bot.telegram.create_inline_markup(
[
'Jan', 'Feb', 'Mar', 'Apr',
'May', 'June', 'July', 'Aug',
'Sept', 'Oct', 'Nov', 'Dec'
],
4
)
telegram_bot.send_message(
message.chat.id,
f"\U0001F4C5 Select month for the creating report",
reply_markup=markup
)
# run bot pulling
telegram.launch_bot()
```

##
GitHub Actions
| Name | Version |
| ------------------------ | ----------- |
| GitHub Actions Templates | [v2.1.1](https://github.com/obervinov/_templates/tree/v2.1.1) |