Struct awesome_bot::AwesomeBot[][src]

pub struct AwesomeBot {
    pub id: Integer,
    pub username: String,
    // some fields omitted
}

Main type for building the Telegram Bot.

Create a new instance using new or from_env, add routing handlers and start the bot.

Fields

The ID of the bot.

The username of the bot.

Methods

impl AwesomeBot
[src]

Creates a new bot with the given token. This checks that the token is a valid Telegram Bot Token by calling get_me. It panics if the token is invalid.

Will receive the Bot Token from the environment variable var and call new. It panics if the environment variable can't be read or if the token is invalid.

Start the bot using getUpdates method, calling the routes defined before calling this method.

Start a SendBuilder directly with the id, this is useful when you have the id saved and want to send a message.

Start a SendBuilder answering a message directly, this is used to answer in a handler to the sender of the message.

impl AwesomeBot
[src]

Methods to add function handlers to different routes.

The different parameters of the handlers are:

Add complex command routing (With capture groups).

This method will transform the pattern to be exhaustive and include the mention to the bot, for example, the pattern echo (.+) will be used inside an the regular expression ^/start(?:@usernamebot)? (.+)$

Add simple command routing (Without capture groups).

This method will transform the pattern the same as command method, but the handler will not receive the capture groups.

Add complex regular expression routing (With capture groups)

This method won't tranform anything about the regular expression, you are free to write the expression you want and receive the capture groups matched.

Add complex regular expression routing (Without capture groups)

This method won't tranform anything about the regular expression, you are free to write the expression. The difference from regex is that you won't receive any capture groups.

Add a routing handler that will be triggerer on every message, useful for logging.

Add a photo media routing handler.

Add a video media routing handler.

Add a document media routing handler.

Add a sticker media routing handler.

Add an audio media routing handler.

Add a voice media routing handler.

Add a routing handler that is triggered when an Audio or a Voice is received.

Add a contact routing handler.

Add a location routing handler.

Add a routing handler that is triggered when a new participant enters a group.

Add a routing handler that is triggered when a participant leaves a group.

Add a routing handler that is triggered when the title of a group chat is changed.

Add a routing handler that is triggered when the photo of a group chat is changed.

Add a routing handler that is triggered when the photo of a group chat is deleted.

Add a routing handler that is triggered when a group chat is created.

Add a routing handler that is triggered when a super group chat is created.

Add a routing handler that is triggered when a channel chat is created.

Trait Implementations

impl Clone for AwesomeBot
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for AwesomeBot

impl Sync for AwesomeBot