Skip to main content

send

Function send 

Source
pub async fn send(msg: &str) -> Result<(), NotifyError>
Expand description

Sends a plain text Telegram message to the configured chat.

The target chat is taken from the TELEGRAM_CHAT_ID environment variable, and the bot token is taken from TELEGRAM_BOT_TOKEN.

§Errors

Returns an error if:

  • required environment variables are missing
  • TELEGRAM_CHAT_ID is invalid
  • the message is empty after trimming
  • the message exceeds Telegram’s 4096 character limit
  • Telegram rejects the request
Examples found in repository?
examples/send.rs (line 5)
4async fn main() -> Result<(), telegram_notify::NotifyError> {
5    send("trade executed").await?;
6    Ok(())
7}