teloxide/examples/self_info.rs
Maybe Waffle c96e46dc6c fmt
I'm too lazy to amend commits...
2022-09-23 18:46:06 +04:00

25 lines
623 B
Rust

use teloxide_core::{
prelude::*,
types::{DiceEmoji, Me, ParseMode},
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
pretty_env_logger::init();
let chat_id = ChatId(
std::env::var("CHAT_ID")
.expect("Expected CHAT_ID env var")
.parse::<i64>()?,
);
let bot = Bot::from_env().parse_mode(ParseMode::MarkdownV2);
let Me { user: me, .. } = bot.get_me().await?;
bot.send_dice(chat_id).emoji(DiceEmoji::Dice).await?;
bot.send_message(chat_id, format!("Hi, my name is **{}** 👋", me.first_name))
.await?;
Ok(())
}