This script sends HTML-formatted messages to Telegram users or chats, leveraging the Telegram Bot API. It calculates values dynamically using commands from a runner (e.g., a Linux server), and customizes messages by substituting template variables with actual values.
To test the script's functionality:
- Edit the
bot-ping.conffile to setBOT_TOKENandNOTIFY_TG_IDSwith your own bot token and Telegram user/chat IDs. - Run the script with the
--send-htmlparameter:./send_message.sh --send-html <path-to-template.html>
All user/chat IDs listed in NOTIFY_TG_IDS in the configuration file will receive a message with:
- Server uptime
- CPU/memory load
- Requested user ID
To use your own variables and messages:
- Modify the
template.htmlfile to include any allowed HTML tags (see the Telegram Bot SDK reference). - Add custom variables using
{{key}}syntax (e.g.,{{my_custom_value}}) withintemplate.html.
- Add corresponding commands in
dynamic_variables.shfor each{{key}}you defined in the HTML template. - The keys in
dynamic_variables.shand{{key}}intemplate.htmlmust match exactly. - Example if you've passed {{my_custom_value}} to html template:
html_vars["my_custom_value"]="some_command_to_get_value"