18 releases (5 breaking)

0.6.5 Jul 16, 2020
0.6.2 May 12, 2020
0.5.2 Mar 31, 2020
0.4.0 Dec 31, 2019
0.1.2 Jul 30, 2019

#73 in Asynchronous

Download history 307/week @ 2020-06-03 128/week @ 2020-06-10 127/week @ 2020-06-17 99/week @ 2020-06-24 151/week @ 2020-07-01 85/week @ 2020-07-08 171/week @ 2020-07-15 113/week @ 2020-07-22 77/week @ 2020-07-29 129/week @ 2020-08-05 110/week @ 2020-08-12 54/week @ 2020-08-19 69/week @ 2020-08-26 168/week @ 2020-09-02 58/week @ 2020-09-09 37/week @ 2020-09-16

438 downloads per month
Used in noce

MIT license

1MB
20K SLoC

tbot

Make cool Telegram bots with Rust easily. For example, here's 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();
}

There are many examples to see tbot in action. If you want to see real-world use of tbot, check out this list.

If you're a newcomer, we recommend you go through the tutorial first. We also have several How-to guides to help you use tbot. You can always refer to our API docs on docs.rs (also, docs for master are available here).

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

Features

  • Full Telegram Bot API 4.9 support, as well as media download/upload, polling and webhooks;
  • async/.await support, built upon tokio;
  • Type-safe and idiomatic API;
  • Easy to use, while scalable and configurable.

Installation

Add tbot and tokio to your Cargo.toml:

[dependencies]
tbot = "0.6"
tokio = { version = "0.2", features = ["macros"] }

tokio is required to start the runtime. You'll also need the macros feature of tokio if you're going to start the runtime using #[tokio::main].

Contribution

Glad you want to contribute to tbot! We develop the crate on GitLab, so create your merge request there if you can. We may accept pull requests on GitHub as well, but we prefer GitLab.

Dependencies

~7–11MB
~218K SLoC