Skip to main content

BotApi

Trait BotApi 

Source
pub trait BotApi: Send + Sync {
    // Required methods
    fn send_message<'life0, 'life1, 'async_trait>(
        &'life0 self,
        chat_id: i64,
        text: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = TelegramResult<i32>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn send_document<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        chat_id: i64,
        file_path: &'life1 Path,
        caption: Option<&'life2 str>,
    ) -> Pin<Box<dyn Future<Output = TelegramResult<i32>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn send_photo<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        chat_id: i64,
        file_path: &'life1 Path,
        caption: Option<&'life2 str>,
    ) -> Pin<Box<dyn Future<Output = TelegramResult<i32>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

Trait abstracting Telegram bot operations for testability.

Production code uses TelegramBot; tests can provide a mock implementation.

Required Methods§

Source

fn send_message<'life0, 'life1, 'async_trait>( &'life0 self, chat_id: i64, text: &'life1 str, ) -> Pin<Box<dyn Future<Output = TelegramResult<i32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send a text message to the given chat.

Returns the Telegram message ID of the sent message.

Source

fn send_document<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, chat_id: i64, file_path: &'life1 Path, caption: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = TelegramResult<i32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Send a document (file) to the given chat with an optional caption.

Returns the Telegram message ID of the sent message.

Source

fn send_photo<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, chat_id: i64, file_path: &'life1 Path, caption: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = TelegramResult<i32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Send a photo to the given chat with an optional caption.

Returns the Telegram message ID of the sent message.

Implementors§