mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-23 06:51:01 +01:00
5922984f6c
In reordering the parameters, I stick the following principle: place parameters from least changing to most changing. Thus, we have config and bot right from the beginning, next a dialogue with a possible payload, and next updates such as messages, inline queries, etc. This principle is used in languages with a native support for currying, although in Rust people appear to order parameters arbitrarily, so this commit is mostly for the sake of consistency.
17 lines
364 B
Rust
17 lines
364 B
Rust
// This bot throws a dice on each incoming message.
|
|
|
|
use teloxide::prelude::*;
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
pretty_env_logger::init();
|
|
log::info!("Starting throw dice bot...");
|
|
|
|
let bot = Bot::from_env();
|
|
|
|
teloxide::repl(bot, |bot: Bot, msg: Message| async move {
|
|
bot.send_dice(msg.chat.id).await?;
|
|
Ok(())
|
|
})
|
|
.await;
|
|
}
|