📦 Telemon
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.
🚀 Features
- Send messages to Telegram topics
- Configuration via
telemon.toml - Optional logging to console
- Flexible usage with or without global
chat_id
🛠 Configuration
Create a telemon.toml file in your project root:
= "BOT_TOKEN" # Your Telegram bot token
= -100xxxxxxx # (Optional) Telegram group chat ID
= false # Set to true to display logs in console
= "HTML" # (Optional) Message format: Markdown, HTML, or empty for plain text
= -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
📤 Usage
You can send messages in two ways, depending on whether chat_id is defined in the config.
1. If chat_id is set in the config
Use .to(topic_id) — the chat_id will be automatically read from the config:
use Telemon;
send.to;
2. If chat_id is not set in the config
You must provide the chat_id as the first value in a tuple:
use Telemon;
send.to;
3. If 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.
send.to_group;
In this case:
- The first value is the
chat_id - The second value is the topic ID within the group
📌 Notes
- If
show_logs = true, every message sent will also be printed to the terminal. - If
show_logs = false, logs will be silent. topic_idrefers to the forum topic ID inside the Telegram group.
✅ Correct Usage in Async Code
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;
let reply = "Hello from async!";
spawn_blocking.await?;


📄 License
MIT License