Modern, fast, and easy to use
It's easy to start making bots with tbot even for comers from other languages, such as Python or JavaScript, thanks to its high-level design. Code written with tbot is easy to read, understand and reason about.
tbot supports async
/.await
, all built upon tokio. This lets you write clean and fast asynchronous code with a rich ecosystem built around tokio.
tbot lets you easily manage your bot's state, be it in memory, in a file or in a database, yet it doesn't constrain you in any way. Also, you can easily work with markup in tbot, without fearing that some user input will break it.
use tbot::prelude::*;
use tokio::sync::Mutex;
#[tokio::main]
async fn main() {
let mut bot = tbot::from_env!("BOT_TOKEN")
.stateful_event_loop(Mutex::new(0));
bot.command("counter", |context, counter| {
async move {
let message = format!(
"The counter is {} now",
*counter.lock().await,
);
context
.send_message(&message)
.call()
.await
.unwrap();
}
});
bot.polling().start().await.unwrap();
}