teloxide/crates/teloxide-core/examples/self_info.rs

22 lines
581 B
Rust
Raw Normal View History

2021-01-13 14:12:04 +01:00
use teloxide_core::{
prelude::*,
types::{DiceEmoji, Me, ParseMode},
2021-01-13 14:12:04 +01:00
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
2021-07-12 15:58:51 +02:00
pretty_env_logger::init();
2022-11-07 13:13:29 +01:00
let chat_id =
ChatId(std::env::var("CHAT_ID").expect("Expected CHAT_ID env var").parse::<i64>()?);
2021-01-13 14:12:04 +01:00
2022-09-23 16:40:54 +02:00
let bot = Bot::from_env().parse_mode(ParseMode::MarkdownV2);
2021-01-13 14:12:04 +01:00
let Me { user: me, .. } = bot.get_me().await?;
2021-01-13 14:12:04 +01:00
2021-01-26 11:43:34 +01:00
bot.send_dice(chat_id).emoji(DiceEmoji::Dice).await?;
2022-11-07 13:13:29 +01:00
bot.send_message(chat_id, format!("Hi, my name is **{}** 👋", me.first_name)).await?;
2021-01-13 14:12:04 +01:00
Ok(())
}