Make cool Telegram bots with Rust easily. For example, here's a simple echo bot:
use tbot::prelude::*;
fn main() {
let mut bot = tbot::bot!("BOT_TOKEN").event_loop();
bot.text(|context| {
let reply = context
.send_message(&context.text.value)
.into_future()
.map_err(|err| {
dbg!(err);
});
tbot::spawn(reply);
});
bot.polling().start();
}
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
.
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.
- Full Bots API support, including media upload/download and recent API updates;
- Support for both polling and webhooks;
- Type-safe API;
- Based on futures and
tokio
; - Easy to use, while scalable and configurable.
Add tbot
to your Cargo.toml:
[dependencies]
tbot = "0.2"
There are many examples in the examples
directory to see tbot
in action.
If you want to get started with tbot
, go through the tutorial. When you
start making your bot, our How-to guides may help you. And you can
always refer to our API docs on docs.rs (docs for master
are
also available here).
Glad you want to contribute to tbot
! We develop the crate on GitLab, so
create your pull/merge request there if you can. We accept pull requests on
GitHub as well, but we prefer GitLab.