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.
- Send messages to Telegram topics
- Configuration via
telemon.toml - Optional logging to console
- Flexible usage with or without global
chat_id
Create 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 topictoken: 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.
Use .to(topic_id) — the chat_id will be automatically read from the config:
use telemon::Telemon;
Telemon::send("✅ Success").to(34);You must provide the chat_id as the first value in a tuple:
use telemon::Telemon;
Telemon::send("🚨 Error occurred").to((-1002483629475, 34));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.
Telemon::send("Hello group!").to_group();In this case:
- The first value is the
chat_id - The second value is the topic ID within the group
- 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.
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

