telegram-notify 1.0.0

Tiny async Rust crate for sending Telegram bot messages
Documentation
  • Coverage
  • 80%
    8 out of 10 items documented1 out of 3 items with examples
  • Size
  • Source code size: 64.95 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.01 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 1m 57s Average build duration of successful builds.
  • all releases: 1m 57s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • fyxtez/telegram-notify
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • fyxtez

telegram-notify

Tiny async Rust crate for sending Telegram bot messages to one configured chat.

Features

  • Minimal send(msg) API
  • Async (Tokio-based)
  • Environment-based configuration
  • Input validation (empty + max length)
  • Lightweight and dependency-minimal

Installation

[dependencies]
telegram-notify = "1.0.0"
tokio = { version = "1", features = ["rt", "macros"] }

Environment

Set these environment variables before sending:

TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id

Usage

use telegram_notify::send;

#[tokio::main]
async fn main() -> Result<(), telegram_notify::NotifyError> {
    send("trade executed").await?;
    Ok(())
}

Getting your chat ID

Run the helper example:

TELEGRAM_BOT_TOKEN=your_bot_token cargo run --example chat_id

Then send any message to your bot in Telegram.

The program will print:

chat_id = 123456789

Use that value as TELEGRAM_CHAT_ID.


Example

TELEGRAM_BOT_TOKEN=your_bot_token \
TELEGRAM_CHAT_ID=123456789 \
cargo run --example send

Behavior

  • Messages are trimmed before sending
  • Empty messages are rejected
  • Messages longer than 4096 characters are rejected (Telegram limit)
  • Errors are returned to the caller

Notes

  • You must manually start the bot in Telegram (/start) before sending messages
  • This crate sends plain text only
  • Designed for simple alerting / notification use cases

License

MIT