mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
.chat_id()
=> .chat.id
This commit is contained in:
parent
ec9f701cf7
commit
5a00e970e4
4 changed files with 26 additions and 26 deletions
14
README.md
14
README.md
|
@ -238,7 +238,7 @@ async fn handle_start(
|
|||
msg: Message,
|
||||
dialogue: MyDialogue,
|
||||
) -> anyhow::Result<()> {
|
||||
bot.send_message(msg.chat_id(), "Let's start! What's your full name?").await?;
|
||||
bot.send_message(msg.chat.id, "Let's start! What's your full name?").await?;
|
||||
dialogue.update(State::ReceiveFullName).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -250,11 +250,11 @@ async fn handle_receive_full_name(
|
|||
) -> anyhow::Result<()> {
|
||||
match msg.text() {
|
||||
Some(text) => {
|
||||
bot.send_message(msg.chat_id(), "How old are you?").await?;
|
||||
bot.send_message(msg.chat.id, "How old are you?").await?;
|
||||
dialogue.update(State::ReceiveAge { full_name: text.into() }).await?;
|
||||
}
|
||||
None => {
|
||||
bot.send_message(msg.chat_id(), "Send me plain text.").await?;
|
||||
bot.send_message(msg.chat.id, "Send me plain text.").await?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,11 +269,11 @@ async fn handle_receive_age(
|
|||
) -> anyhow::Result<()> {
|
||||
match msg.text().map(|text| text.parse::<u8>()) {
|
||||
Some(Ok(age)) => {
|
||||
bot.send_message(msg.chat_id(), "What's your location?").await?;
|
||||
bot.send_message(msg.chat.id, "What's your location?").await?;
|
||||
dialogue.update(State::ReceiveLocation { full_name, age }).await?;
|
||||
}
|
||||
_ => {
|
||||
bot.send_message(msg.chat_id(), "Send me a number.").await?;
|
||||
bot.send_message(msg.chat.id, "Send me a number.").await?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -289,11 +289,11 @@ async fn handle_receive_location(
|
|||
match msg.text() {
|
||||
Some(location) => {
|
||||
let message = format!("Full name: {}\nAge: {}\nLocation: {}", full_name, age, location);
|
||||
bot.send_message(msg.chat_id(), message).await?;
|
||||
bot.send_message(msg.chat.id, message).await?;
|
||||
dialogue.exit().await?;
|
||||
}
|
||||
None => {
|
||||
bot.send_message(msg.chat_id(), "Send me plain text.").await?;
|
||||
bot.send_message(msg.chat.id, "Send me plain text.").await?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,10 +69,10 @@ async fn kick_user(bot: Bot, msg: Message) -> Result<(), Box<dyn Error + Send +
|
|||
match msg.reply_to_message() {
|
||||
Some(replied) => {
|
||||
// bot.unban_chat_member can also kicks a user from a group chat.
|
||||
bot.unban_chat_member(msg.chat_id(), replied.from().unwrap().id).await?;
|
||||
bot.unban_chat_member(msg.chat.id, replied.from().unwrap().id).await?;
|
||||
}
|
||||
None => {
|
||||
bot.send_message(msg.chat_id(), "Use this command in reply to another message").await?;
|
||||
bot.send_message(msg.chat.id, "Use this command in reply to another message").await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -87,7 +87,7 @@ async fn mute_user(
|
|||
match msg.reply_to_message() {
|
||||
Some(replied) => {
|
||||
bot.restrict_chat_member(
|
||||
msg.chat_id(),
|
||||
msg.chat.id,
|
||||
replied.from().expect("Must be MessageKind::Common").id,
|
||||
ChatPermissions::empty(),
|
||||
)
|
||||
|
@ -95,7 +95,7 @@ async fn mute_user(
|
|||
.await?;
|
||||
}
|
||||
None => {
|
||||
bot.send_message(msg.chat_id(), "Use this command in a reply to another message!")
|
||||
bot.send_message(msg.chat.id, "Use this command in a reply to another message!")
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
@ -111,14 +111,14 @@ async fn ban_user(
|
|||
match msg.reply_to_message() {
|
||||
Some(replied) => {
|
||||
bot.kick_chat_member(
|
||||
msg.chat_id(),
|
||||
msg.chat.id,
|
||||
replied.from().expect("Must be MessageKind::Common").id,
|
||||
)
|
||||
.until_date(msg.date + time)
|
||||
.await?;
|
||||
}
|
||||
None => {
|
||||
bot.send_message(msg.chat_id(), "Use this command in a reply to another message!")
|
||||
bot.send_message(msg.chat.id, "Use this command in a reply to another message!")
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ async fn action(
|
|||
) -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
match command {
|
||||
Command::Help => {
|
||||
bot.send_message(msg.chat_id(), Command::descriptions()).await?;
|
||||
bot.send_message(msg.chat.id, Command::descriptions()).await?;
|
||||
}
|
||||
Command::Kick => kick_user(bot, msg).await?,
|
||||
Command::Ban { time, unit } => ban_user(bot, msg, calc_restrict_time(time, unit)).await?,
|
||||
|
|
|
@ -64,7 +64,7 @@ async fn handle_start(
|
|||
msg: Message,
|
||||
dialogue: MyDialogue,
|
||||
) -> anyhow::Result<()> {
|
||||
bot.send_message(msg.chat_id(), "Let's start! What's your full name?").await?;
|
||||
bot.send_message(msg.chat.id, "Let's start! What's your full name?").await?;
|
||||
dialogue.update(State::ReceiveFullName).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -76,11 +76,11 @@ async fn handle_receive_full_name(
|
|||
) -> anyhow::Result<()> {
|
||||
match msg.text() {
|
||||
Some(text) => {
|
||||
bot.send_message(msg.chat_id(), "How old are you?").await?;
|
||||
bot.send_message(msg.chat.id, "How old are you?").await?;
|
||||
dialogue.update(State::ReceiveAge { full_name: text.into() }).await?;
|
||||
}
|
||||
None => {
|
||||
bot.send_message(msg.chat_id(), "Send me plain text.").await?;
|
||||
bot.send_message(msg.chat.id, "Send me plain text.").await?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,11 +95,11 @@ async fn handle_receive_age(
|
|||
) -> anyhow::Result<()> {
|
||||
match msg.text().map(|text| text.parse::<u8>()) {
|
||||
Some(Ok(age)) => {
|
||||
bot.send_message(msg.chat_id(), "What's your location?").await?;
|
||||
bot.send_message(msg.chat.id, "What's your location?").await?;
|
||||
dialogue.update(State::ReceiveLocation { full_name, age }).await?;
|
||||
}
|
||||
_ => {
|
||||
bot.send_message(msg.chat_id(), "Send me a number.").await?;
|
||||
bot.send_message(msg.chat.id, "Send me a number.").await?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,11 +115,11 @@ async fn handle_receive_location(
|
|||
match msg.text() {
|
||||
Some(location) => {
|
||||
let message = format!("Full name: {}\nAge: {}\nLocation: {}", full_name, age, location);
|
||||
bot.send_message(msg.chat_id(), message).await?;
|
||||
bot.send_message(msg.chat.id, message).await?;
|
||||
dialogue.exit().await?;
|
||||
}
|
||||
None => {
|
||||
bot.send_message(msg.chat_id(), "Send me plain text.").await?;
|
||||
bot.send_message(msg.chat.id, "Send me plain text.").await?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,15 +43,15 @@
|
|||
//! match msg.text() {
|
||||
//! Some(number) => match number.parse::<u8>() {
|
||||
//! Ok(age) => {
|
||||
//! bot.send_message(msg.chat_id(), "What's your location?").await?;
|
||||
//! bot.send_message(msg.chat.id, "What's your location?").await?;
|
||||
//! dialogue.update(State::ReceiveLocation { full_name, age }).await?;
|
||||
//! }
|
||||
//! _ => {
|
||||
//! bot.send_message(msg.chat_id(), "Send me a number.").await?;
|
||||
//! bot.send_message(msg.chat.id, "Send me a number.").await?;
|
||||
//! }
|
||||
//! },
|
||||
//! None => {
|
||||
//! bot.send_message(msg.chat_id(), "Send me a text message.").await?;
|
||||
//! bot.send_message(msg.chat.id, "Send me a text message.").await?;
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
|
@ -76,11 +76,11 @@
|
|||
//! Some(location) => {
|
||||
//! let message =
|
||||
//! format!("Full name: {}\nAge: {}\nLocation: {}", full_name, age, location);
|
||||
//! bot.send_message(msg.chat_id(), message).await?;
|
||||
//! bot.send_message(msg.chat.id, message).await?;
|
||||
//! dialogue.exit().await?;
|
||||
//! }
|
||||
//! None => {
|
||||
//! bot.send_message(msg.chat_id(), "Send me a text message.").await?;
|
||||
//! bot.send_message(msg.chat.id, "Send me a text message.").await?;
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
|
|
Loading…
Reference in a new issue