mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Simplify examples/dialogue.rs
This commit is contained in:
parent
7837db4201
commit
263478a20a
2 changed files with 18 additions and 28 deletions
23
README.md
23
README.md
|
@ -254,7 +254,7 @@ async fn handle_receive_full_name(
|
|||
dialogue.update(State::ReceiveAge { full_name: text.into() }).await?;
|
||||
}
|
||||
None => {
|
||||
bot.send_message(msg.chat_id(), "Send me a text message.").await?;
|
||||
bot.send_message(msg.chat_id(), "Send me plain text.").await?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,18 +267,13 @@ async fn handle_receive_age(
|
|||
dialogue: MyDialogue,
|
||||
(full_name,): (String,),
|
||||
) -> anyhow::Result<()> {
|
||||
match msg.text() {
|
||||
Some(number) => match number.parse::<u8>() {
|
||||
Ok(age) => {
|
||||
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?;
|
||||
}
|
||||
},
|
||||
None => {
|
||||
bot.send_message(msg.chat_id(), "Send me a text message.").await?;
|
||||
match msg.text().map(|text| text.parse::<u8>()) {
|
||||
Some(Ok(age)) => {
|
||||
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?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -298,7 +293,7 @@ async fn handle_receive_location(
|
|||
dialogue.exit().await?;
|
||||
}
|
||||
None => {
|
||||
bot.send_message(msg.chat_id(), "Send me a text message.").await?;
|
||||
bot.send_message(msg.chat_id(), "Send me plain text.").await?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ async fn handle_receive_full_name(
|
|||
dialogue.update(State::ReceiveAge { full_name: text.into() }).await?;
|
||||
}
|
||||
None => {
|
||||
bot.send_message(msg.chat_id(), "Send me a text message.").await?;
|
||||
bot.send_message(msg.chat_id(), "Send me plain text.").await?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,18 +93,13 @@ async fn handle_receive_age(
|
|||
dialogue: MyDialogue,
|
||||
(full_name,): (String,),
|
||||
) -> anyhow::Result<()> {
|
||||
match msg.text() {
|
||||
Some(number) => match number.parse::<u8>() {
|
||||
Ok(age) => {
|
||||
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?;
|
||||
}
|
||||
},
|
||||
None => {
|
||||
bot.send_message(msg.chat_id(), "Send me a text message.").await?;
|
||||
match msg.text().map(|text| text.parse::<u8>()) {
|
||||
Some(Ok(age)) => {
|
||||
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?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,7 +119,7 @@ async fn handle_receive_location(
|
|||
dialogue.exit().await?;
|
||||
}
|
||||
None => {
|
||||
bot.send_message(msg.chat_id(), "Send me a text message.").await?;
|
||||
bot.send_message(msg.chat_id(), "Send me plain text.").await?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue