| Crates.io | telemon |
| lib.rs | telemon |
| version | 0.2.2 |
| created_at | 2025-03-28 15:20:43.531966+00 |
| updated_at | 2025-04-01 11:11:08.045492+00 |
| description | A Telegram bot for sending log messages to group topics. |
| homepage | |
| repository | https://github.com/encoderuz/telemon |
| max_upload_size | |
| id | 1609751 |
| size | 2,144,370 |
Telemon is a lightweight Rust library for sending logs or messages to a Telegram group using a bot. It supports topic-based messaging and flexible configuration through a telemon.toml file.
telemon.tomlchat_idCreate a telemon.toml file in your project root:
token = "BOT_TOKEN" # Your Telegram bot token
chat_id = -100xxxxxxx # (Optional) Telegram group chat ID
show_logs = false # Set to true to display logs in console
parse_mode = "HTML" # (Optional) Message format: Markdown, HTML, or empty for plain text
group_id = -100xxxxxx # (Optional) Use this if you only want to send messages to a group, not to a specific topic
token: The bot token provided by BotFatherchat_id: (Optional) The group chat ID where messages will be sentshow_logs: If true, logs will also be printed to the terminalparse_mode: Defines the message format sent to Telegram. Accepted values are: Markdown, MarkdownV2, Htmlgroup_id (Optional) Used to send messages directly to a Telegram group without specifying a topic (i.e., for non-forum groups).Markdown – Enables Markdown formatting
HTML – Enables HTML formatting
Leave empty or omit for plain text
You can send messages in two ways, depending on whether chat_id is defined in the config.
chat_id is set in the configUse .to(topic_id) — the chat_id will be automatically read from the config:
use telemon::Telemon;
Telemon::send("✅ Success").to(34);
chat_id is not set in the configYou must provide the chat_id as the first value in a tuple:
use telemon::Telemon;
Telemon::send("🚨 Error occurred").to((-1002483629475, 34));
group_id is set (and chat_id is not used), you can send messages using the .to_group() method, which does not require a thread ID.Telemon::send("Hello group!").to_group();
In this case:
chat_idIf show_logs = true, every message sent will also be printed to the terminal.
If show_logs = false, logs will be silent.
topic_id refers to the forum topic ID inside the Telegram group.
To safely call a blocking function such as Telemon::send inside an async function, wrap it with tokio::task::spawn_blocking. This runs the operation on a separate thread, ensuring that your async runtime remains non-blocked:
use telemon::Telemon;
let reply = "Hello from async!";
tokio::task::spawn_blocking(move || {
Telemon::send(&reply).to(2)
}).await?;


MIT License