This package helps to easily and quickly generate beautiful messages for telegram bots using templates described in json.
- Rendering a line with progress bar
- Rendering a line with emoji
- Rendering a simple string
Variable | Description | Default value |
---|---|---|
MESSAGES_CONFIG |
Json file with templates for rendering messages. Example | configs/messages.json |
tee -a pyproject.toml <<EOF
[tool.poetry]
name = myproject"
version = "1.0.0"
[tool.poetry.dependencies]
python = "^3.12"
messages = { git = "https://github.com/obervinov/messages-package.git", tag = "v2.0.0" }
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
EOF
poetry install
- Creating configs/messages.json and adding an example template
- all emojis should be wrapped in
:
- all variables must be specified in the same form as in your code
- all emojis should be wrapped in
{
"templates": {
"hello_message": {
"text": "Hi, <b>{0}</b>! {1}\nAccess for your account - allowed {2}",
"args": ["username", ":raised_hand:", ":unlocked:"]
}
}
}
# Import module
from messages import Messages
# Create instance
messages = Messages()
# Rendering and getting messages
print(
messages.render_template(
template_alias='hello_message',
username="obervinov"
)
)
output result
Hi, <b>obervinov</b>! ✋
Access for your account - allowed 🔓
- Creating configs/messages.json and adding an example template
- all emojis should be wrapped in
:
- all variables must be specified in the same form as in your code
- all emojis should be wrapped in
{
"templates": {
"queue_message": {
"text": "{0} Messages from the queue have already been processed\n{1}",
"args": [":framed_picture:", "progressbar"]
}
}
}
# Import module
from messages import Messages
# Create instance
messages = Messages()
# Render and get messages with progress bar
print(
messages.render_template(
template_alias='queue_message',
progressbar=messages.render_progressbar(
total_count=100,
current_count=19
)
)
)
output result
🏞 Messages from the queue have already been processed
[◾◾◾◾◾◾◾◾◾◾◾◾◾◾◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️◻️]19%
Name | Version |
---|---|
GitHub Actions Templates | v2.0.0 |