Module telers::methods

source ·
Expand description

This module contains telegram methods from the Telegram Bot API. Each method has a description and a link to the official documentation.

Telegram methods are represented by structs that implement the TelegramMethod trait. Each method has new function that creates a new instance of the method and accepts required parameters, for optional parameters there are builder-like methods that return a new instance of the method with the specified parameter.

§Examples

Some parameters that wrapped in an Option from the telegram types, can be passed using {parameter}_option method, which accepts an Option and returns a new instance of the method. These methods are useful when you have some optional parameters that you want to pass to the method from the types without boilerplate code.

use telers::{Bot, methods::SendMessage, types::Message, event::{telegram::HandlerResult, EventReturn}};

async fn handler(bot: Bot, message: Message) -> HandlerResult {
    bot.send(SendMessage::new(message.chat().id(), "Hello world!").message_thread_id_option(message.thread_id())).await?;

    Ok(EventReturn::Finish)
}

You can check more examples of usage methods in the examples directory.

Re-exports§

Modules§