fix examples (because get_me now returns Me)

This commit is contained in:
Waffle 2021-01-26 14:10:37 +03:00
parent a80ff92aba
commit 8807cd7228
3 changed files with 9 additions and 6 deletions

View file

@ -1,6 +1,6 @@
use teloxide_core::{
prelude::*,
types::{DiceEmoji, ParseMode},
types::{DiceEmoji, Me, ParseMode},
};
#[tokio::main]
@ -13,7 +13,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.parse_mode(ParseMode::MarkdownV2)
.auto_send();
let me = bot.get_me().await?;
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))

View file

@ -25,8 +25,11 @@
//! let 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?;
//! bot.send_message(
//! chat_id,
//! format!("Hi, my name is **{}** 👋", me.user.first_name),
//! )
//! .await?;
//! # Ok::<_, Box<dyn std::error::Error>>(()) };
//! ```
//!

View file

@ -44,7 +44,7 @@ pub trait Request: HasPayload {
/// use teloxide_core::{
/// payloads::GetMe,
/// requests::{JsonRequest, Request},
/// types::User,
/// types::Me,
/// Bot,
/// };
///
@ -53,7 +53,7 @@ pub trait Request: HasPayload {
/// // Note: it's recommended to `Requester` instead of creating requests directly
/// let method = GetMe::new();
/// let request = JsonRequest::new(bot, method);
/// let _: User = request.send().await.unwrap();
/// let _: Me = request.send().await.unwrap();
/// # };
/// ```
fn send(self) -> Self::Send;