[][src]Crate tbot

Make cool Telegram bots with Rust easily. Here is a simple echo bot:

use tbot::prelude::*;

#[tokio::main]
async fn main() {
    let mut bot = tbot::from_env!("BOT_TOKEN").event_loop();

    bot.text(|context| {
        async move {
            let echo = &context.text.value;
            let call_result = context.send_message(echo).call().await;

            if let Err(err) = call_result {
                dbg!(err);
            }
        }
    });

    bot.polling().start().await.unwrap();
}

If you're new to tbot, we recommend you go through the tutorial first. We also have several How-to guides with snippets to solve your problems.

If you have a question, ask it in our group on Telegram. If you find a bug, fill an issue on either our GitLab or GitHub repository.

Re-exports

pub use event_loop::EventLoop;

Modules

connectors

A few common connectors for making requests.

contexts

Contexts for update handlers.

errors

Types representing errors.

event_loop

The event loop for handling bot updates.

methods

Structs for calling API methods.

prelude

Traits needed when working with tbot.

types

Types for interacting with the API.

Macros

from_env

Constructs a new Bot, extracting the token from the environment at compile time.

Structs

Bot

Provides methods to call the Bots API.