Struct pling::Telegram[][src]

pub struct Telegram {
    pub bot_token: String,
    pub target_chat: TargetChat,
    pub disable_web_page_preview: bool,
    pub disable_notification: bool,
}
Expand description

Send a Telegram message

Documentation

Needs to be compiled with feature http-sync or http-async

Usage TLDR

  • Create BOT_TOKEN via @BotFather in Telegram
  • Add the created bot to the chat/channel or write the bot a first message
  • Somehow obtain the Chat/User ID or Chat/Channel Username (TODO) that should receive the notification

Environment Variables

  • TELEGRAM_BOT_TOKEN (required)
  • TELEGRAM_TARGET_CHAT (required)
  • TELEGRAM_DISABLE_WEB_PAGE_PREVIEW (optional)
  • TELEGRAM_DISABLE_NOTIFICATION (optional)

Fields

bot_token: Stringtarget_chat: TargetChatdisable_web_page_preview: booldisable_notification: bool

Implementations

Loads the Telegram config from environment variables. The following variables are used:

  • TELEGRAM_BOT_TOKEN
  • TELEGRAM_TARGET_CHAT
  • TELEGRAM_DISABLE_WEB_PAGE_PREVIEW
  • TELEGRAM_DISABLE_NOTIFICATION

When TELEGRAM_BOT_TOKEN or TELEGRAM_TARGET_CHAT are unset None is returned.

Send a Telegram notification synchronously.

Errors

This method errors when the request could not be send or the not be handled by the Telegram API.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.