mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
Reorder parameters in the examples
In reordering the parameters, I stick the following principle: place parameters from least changing to most changing. Thus, we have config and bot right from the beginning, next a dialogue with a possible payload, and next updates such as messages, inline queries, etc. This principle is used in languages with a native support for currying, although in Rust people appear to order parameters arbitrarily, so this commit is mostly for the sake of consistency.
Former-commit-id: 5922984f6c
This commit is contained in:
parent
d3d7cc2fa9
commit
53be9d0e92
14 changed files with 47 additions and 52 deletions
29
README.md
29
README.md
|
@ -94,7 +94,7 @@ async fn main() {
|
||||||
|
|
||||||
let bot = Bot::from_env();
|
let bot = Bot::from_env();
|
||||||
|
|
||||||
teloxide::repl(bot, |message: Message, bot: Bot| async move {
|
teloxide::repl(bot, |bot: Bot, msg: Message| async move {
|
||||||
bot.send_dice(message.chat.id).await?;
|
bot.send_dice(message.chat.id).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
|
@ -143,19 +143,14 @@ enum Command {
|
||||||
UsernameAndAge { username: String, age: u8 },
|
UsernameAndAge { username: String, age: u8 },
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn answer(bot: Bot, message: Message, command: Command) -> ResponseResult<()> {
|
async fn answer(bot: Bot, msg: Message, cmd: Command) -> ResponseResult<()> {
|
||||||
match command {
|
match cmd {
|
||||||
Command::Help => {
|
Command::Help => bot.send_message(msg.chat.id, Command::descriptions().to_string()).await?,
|
||||||
bot.send_message(message.chat.id, Command::descriptions().to_string()).await?
|
|
||||||
}
|
|
||||||
Command::Username(username) => {
|
Command::Username(username) => {
|
||||||
bot.send_message(message.chat.id, format!("Your username is @{username}.")).await?
|
bot.send_message(msg.chat.id, format!("Your username is @{username}.")).await?
|
||||||
}
|
}
|
||||||
Command::UsernameAndAge { username, age } => {
|
Command::UsernameAndAge { username, age } => {
|
||||||
bot.send_message(
|
bot.send_message(msg.chat.id, format!("Your username is @{username} and age is {age}."))
|
||||||
message.chat.id,
|
|
||||||
format!("Your username is @{username} and age is {age}."),
|
|
||||||
)
|
|
||||||
.await?
|
.await?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -223,13 +218,13 @@ async fn main() {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn start(bot: Bot, msg: Message, dialogue: MyDialogue) -> HandlerResult {
|
async fn start(bot: Bot, dialogue: MyDialogue, msg: Message) -> HandlerResult {
|
||||||
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?;
|
dialogue.update(State::ReceiveFullName).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn receive_full_name(bot: Bot, msg: Message, dialogue: MyDialogue) -> HandlerResult {
|
async fn receive_full_name(bot: Bot, dialogue: MyDialogue, msg: Message) -> HandlerResult {
|
||||||
match msg.text() {
|
match msg.text() {
|
||||||
Some(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?;
|
||||||
|
@ -245,9 +240,9 @@ async fn receive_full_name(bot: Bot, msg: Message, dialogue: MyDialogue) -> Hand
|
||||||
|
|
||||||
async fn receive_age(
|
async fn receive_age(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
msg: Message,
|
|
||||||
dialogue: MyDialogue,
|
dialogue: MyDialogue,
|
||||||
full_name: String, // Available from `State::ReceiveAge`.
|
full_name: String, // Available from `State::ReceiveAge`.
|
||||||
|
msg: Message,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
match msg.text().map(|text| text.parse::<u8>()) {
|
match msg.text().map(|text| text.parse::<u8>()) {
|
||||||
Some(Ok(age)) => {
|
Some(Ok(age)) => {
|
||||||
|
@ -264,14 +259,14 @@ async fn receive_age(
|
||||||
|
|
||||||
async fn receive_location(
|
async fn receive_location(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
msg: Message,
|
|
||||||
dialogue: MyDialogue,
|
dialogue: MyDialogue,
|
||||||
(full_name, age): (String, u8), // Available from `State::ReceiveLocation`.
|
(full_name, age): (String, u8), // Available from `State::ReceiveLocation`.
|
||||||
|
msg: Message,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
match msg.text() {
|
match msg.text() {
|
||||||
Some(location) => {
|
Some(location) => {
|
||||||
let message = format!("Full name: {full_name}\nAge: {age}\nLocation: {location}");
|
let report = format!("Full name: {full_name}\nAge: {age}\nLocation: {location}");
|
||||||
bot.send_message(msg.chat.id, message).await?;
|
bot.send_message(msg.chat.id, report).await?;
|
||||||
dialogue.exit().await?;
|
dialogue.exit().await?;
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
|
|
@ -59,8 +59,8 @@ fn make_keyboard() -> InlineKeyboardMarkup {
|
||||||
/// or not, then match the command. If the command is `/start` it writes a
|
/// or not, then match the command. If the command is `/start` it writes a
|
||||||
/// markup with the `InlineKeyboardMarkup`.
|
/// markup with the `InlineKeyboardMarkup`.
|
||||||
async fn message_handler(
|
async fn message_handler(
|
||||||
msg: Message,
|
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
|
msg: Message,
|
||||||
me: Me,
|
me: Me,
|
||||||
) -> Result<(), Box<dyn Error + Send + Sync>> {
|
) -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||||
if let Some(text) = msg.text() {
|
if let Some(text) = msg.text() {
|
||||||
|
@ -85,8 +85,8 @@ async fn message_handler(
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn inline_query_handler(
|
async fn inline_query_handler(
|
||||||
q: InlineQuery,
|
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
|
q: InlineQuery,
|
||||||
) -> Result<(), Box<dyn Error + Send + Sync>> {
|
) -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||||
let choose_debian_version = InlineQueryResultArticle::new(
|
let choose_debian_version = InlineQueryResultArticle::new(
|
||||||
"0",
|
"0",
|
||||||
|
@ -105,7 +105,7 @@ async fn inline_query_handler(
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: do not send privacy-sensitive data this way!!!
|
/// **IMPORTANT**: do not send privacy-sensitive data this way!!!
|
||||||
/// Anyone can read data stored in the callback button.
|
/// Anyone can read data stored in the callback button.
|
||||||
async fn callback_handler(q: CallbackQuery, bot: Bot) -> Result<(), Box<dyn Error + Send + Sync>> {
|
async fn callback_handler(bot: Bot, q: CallbackQuery) -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||||
if let Some(version) = q.data {
|
if let Some(version) = q.data {
|
||||||
let text = format!("You chose: {version}");
|
let text = format!("You chose: {version}");
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ async fn main() {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn start(bot: Bot, msg: Message, dialogue: MyDialogue) -> HandlerResult {
|
async fn start(bot: Bot, dialogue: MyDialogue, msg: Message) -> HandlerResult {
|
||||||
match msg.text().map(|text| text.parse::<i32>()) {
|
match msg.text().map(|text| text.parse::<i32>()) {
|
||||||
Some(Ok(n)) => {
|
Some(Ok(n)) => {
|
||||||
dialogue.update(State::GotNumber(n)).await?;
|
dialogue.update(State::GotNumber(n)).await?;
|
||||||
|
@ -80,9 +80,9 @@ async fn start(bot: Bot, msg: Message, dialogue: MyDialogue) -> HandlerResult {
|
||||||
|
|
||||||
async fn got_number(
|
async fn got_number(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
msg: Message,
|
|
||||||
dialogue: MyDialogue,
|
dialogue: MyDialogue,
|
||||||
num: i32,
|
num: i32, // Available from `State::GotNumber`.
|
||||||
|
msg: Message,
|
||||||
cmd: Command,
|
cmd: Command,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
match cmd {
|
match cmd {
|
||||||
|
|
|
@ -57,13 +57,13 @@ async fn main() {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn start(bot: Bot, msg: Message, dialogue: MyDialogue) -> HandlerResult {
|
async fn start(bot: Bot, dialogue: MyDialogue, msg: Message) -> HandlerResult {
|
||||||
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?;
|
dialogue.update(State::ReceiveFullName).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn receive_full_name(bot: Bot, msg: Message, dialogue: MyDialogue) -> HandlerResult {
|
async fn receive_full_name(bot: Bot, dialogue: MyDialogue, msg: Message) -> HandlerResult {
|
||||||
match msg.text() {
|
match msg.text() {
|
||||||
Some(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?;
|
||||||
|
@ -79,9 +79,9 @@ async fn receive_full_name(bot: Bot, msg: Message, dialogue: MyDialogue) -> Hand
|
||||||
|
|
||||||
async fn receive_age(
|
async fn receive_age(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
msg: Message,
|
|
||||||
dialogue: MyDialogue,
|
dialogue: MyDialogue,
|
||||||
full_name: String, // Available from `State::ReceiveAge`.
|
full_name: String, // Available from `State::ReceiveAge`.
|
||||||
|
msg: Message,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
match msg.text().map(|text| text.parse::<u8>()) {
|
match msg.text().map(|text| text.parse::<u8>()) {
|
||||||
Some(Ok(age)) => {
|
Some(Ok(age)) => {
|
||||||
|
@ -98,9 +98,9 @@ async fn receive_age(
|
||||||
|
|
||||||
async fn receive_location(
|
async fn receive_location(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
msg: Message,
|
|
||||||
dialogue: MyDialogue,
|
dialogue: MyDialogue,
|
||||||
(full_name, age): (String, u8), // Available from `State::ReceiveLocation`.
|
(full_name, age): (String, u8), // Available from `State::ReceiveLocation`.
|
||||||
|
msg: Message,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
match msg.text() {
|
match msg.text() {
|
||||||
Some(location) => {
|
Some(location) => {
|
||||||
|
|
|
@ -33,7 +33,7 @@ async fn main() {
|
||||||
)
|
)
|
||||||
.branch(
|
.branch(
|
||||||
// Filter a maintainer by a used ID.
|
// Filter a maintainer by a used ID.
|
||||||
dptree::filter(|msg: Message, cfg: ConfigParameters| {
|
dptree::filter(|cfg: ConfigParameters, msg: Message| {
|
||||||
msg.from().map(|user| user.id == cfg.bot_maintainer).unwrap_or_default()
|
msg.from().map(|user| user.id == cfg.bot_maintainer).unwrap_or_default()
|
||||||
})
|
})
|
||||||
.filter_command::<MaintainerCommands>()
|
.filter_command::<MaintainerCommands>()
|
||||||
|
@ -62,7 +62,7 @@ async fn main() {
|
||||||
.branch(
|
.branch(
|
||||||
// There are some extension filtering functions on `Message`. The following filter will
|
// There are some extension filtering functions on `Message`. The following filter will
|
||||||
// filter only messages with dices.
|
// filter only messages with dices.
|
||||||
Message::filter_dice().endpoint(|msg: Message, dice: Dice, bot: Bot| async move {
|
Message::filter_dice().endpoint(|bot: Bot, msg: Message, dice: Dice| async move {
|
||||||
bot.send_message(msg.chat.id, format!("Dice value: {}", dice.value))
|
bot.send_message(msg.chat.id, format!("Dice value: {}", dice.value))
|
||||||
.reply_to_message_id(msg.id)
|
.reply_to_message_id(msg.id)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -114,11 +114,11 @@ enum MaintainerCommands {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn simple_commands_handler(
|
async fn simple_commands_handler(
|
||||||
msg: Message,
|
|
||||||
bot: Bot,
|
|
||||||
cmd: SimpleCommand,
|
|
||||||
cfg: ConfigParameters,
|
cfg: ConfigParameters,
|
||||||
|
bot: Bot,
|
||||||
me: teloxide::types::Me,
|
me: teloxide::types::Me,
|
||||||
|
msg: Message,
|
||||||
|
cmd: SimpleCommand,
|
||||||
) -> Result<(), teloxide::RequestError> {
|
) -> Result<(), teloxide::RequestError> {
|
||||||
let text = match cmd {
|
let text = match cmd {
|
||||||
SimpleCommand::Help => {
|
SimpleCommand::Help => {
|
||||||
|
|
|
@ -47,7 +47,7 @@ async fn main() {
|
||||||
|
|
||||||
teloxide::repl_with_listener(
|
teloxide::repl_with_listener(
|
||||||
bot,
|
bot,
|
||||||
|msg: Message, bot: Bot| async move {
|
|bot: Bot, msg: Message| async move {
|
||||||
bot.send_message(msg.chat.id, "pong").await?;
|
bot.send_message(msg.chat.id, "pong").await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,7 +14,7 @@ async fn main() {
|
||||||
let bot = Bot::from_env();
|
let bot = Bot::from_env();
|
||||||
|
|
||||||
let handler = Update::filter_inline_query().branch(dptree::endpoint(
|
let handler = Update::filter_inline_query().branch(dptree::endpoint(
|
||||||
|q: InlineQuery, bot: Bot| async move {
|
|bot: Bot, q: InlineQuery| async move {
|
||||||
// First, create your actual response
|
// First, create your actual response
|
||||||
let google_search = InlineQueryResultArticle::new(
|
let google_search = InlineQueryResultArticle::new(
|
||||||
// Each item needs a unique ID, as well as the response container for the
|
// Each item needs a unique ID, as well as the response container for the
|
||||||
|
|
|
@ -18,7 +18,7 @@ async fn main() {
|
||||||
|
|
||||||
teloxide::repl_with_listener(
|
teloxide::repl_with_listener(
|
||||||
bot,
|
bot,
|
||||||
|msg: Message, bot: Bot| async move {
|
|bot: Bot, msg: Message| async move {
|
||||||
bot.send_message(msg.chat.id, "pong").await?;
|
bot.send_message(msg.chat.id, "pong").await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
|
|
|
@ -83,7 +83,7 @@ fn schema() -> UpdateHandler<Box<dyn std::error::Error + Send + Sync + 'static>>
|
||||||
.branch(callback_query_handler)
|
.branch(callback_query_handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn start(bot: Bot, msg: Message, dialogue: MyDialogue) -> HandlerResult {
|
async fn start(bot: Bot, dialogue: MyDialogue, msg: Message) -> HandlerResult {
|
||||||
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?;
|
dialogue.update(State::ReceiveFullName).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -94,7 +94,7 @@ async fn help(bot: Bot, msg: Message) -> HandlerResult {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn cancel(bot: Bot, msg: Message, dialogue: MyDialogue) -> HandlerResult {
|
async fn cancel(bot: Bot, dialogue: MyDialogue, msg: Message) -> HandlerResult {
|
||||||
bot.send_message(msg.chat.id, "Cancelling the dialogue.").await?;
|
bot.send_message(msg.chat.id, "Cancelling the dialogue.").await?;
|
||||||
dialogue.exit().await?;
|
dialogue.exit().await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -106,7 +106,7 @@ async fn invalid_state(bot: Bot, msg: Message) -> HandlerResult {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn receive_full_name(bot: Bot, msg: Message, dialogue: MyDialogue) -> HandlerResult {
|
async fn receive_full_name(bot: Bot, dialogue: MyDialogue, msg: Message) -> HandlerResult {
|
||||||
match msg.text().map(ToOwned::to_owned) {
|
match msg.text().map(ToOwned::to_owned) {
|
||||||
Some(full_name) => {
|
Some(full_name) => {
|
||||||
let products = ["Apple", "Banana", "Orange", "Potato"]
|
let products = ["Apple", "Banana", "Orange", "Potato"]
|
||||||
|
@ -127,9 +127,9 @@ async fn receive_full_name(bot: Bot, msg: Message, dialogue: MyDialogue) -> Hand
|
||||||
|
|
||||||
async fn receive_product_selection(
|
async fn receive_product_selection(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
q: CallbackQuery,
|
|
||||||
dialogue: MyDialogue,
|
dialogue: MyDialogue,
|
||||||
full_name: String,
|
full_name: String, // Available from `State::ReceiveProductChoice`.
|
||||||
|
q: CallbackQuery,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
if let Some(product) = &q.data {
|
if let Some(product) = &q.data {
|
||||||
bot.send_message(
|
bot.send_message(
|
||||||
|
|
|
@ -16,7 +16,7 @@ async fn main() {
|
||||||
let messages_total = Arc::new(AtomicU64::new(0));
|
let messages_total = Arc::new(AtomicU64::new(0));
|
||||||
|
|
||||||
let handler = Update::filter_message().endpoint(
|
let handler = Update::filter_message().endpoint(
|
||||||
|msg: Message, bot: Bot, messages_total: Arc<AtomicU64>| async move {
|
|bot: Bot, messages_total: Arc<AtomicU64>, msg: Message| async move {
|
||||||
let previous = messages_total.fetch_add(1, Ordering::Relaxed);
|
let previous = messages_total.fetch_add(1, Ordering::Relaxed);
|
||||||
bot.send_message(msg.chat.id, format!("I received {previous} messages in total."))
|
bot.send_message(msg.chat.id, format!("I received {previous} messages in total."))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
@ -9,7 +9,7 @@ async fn main() {
|
||||||
|
|
||||||
let bot = Bot::from_env();
|
let bot = Bot::from_env();
|
||||||
|
|
||||||
teloxide::repl(bot, |msg: Message, bot: Bot| async move {
|
teloxide::repl(bot, |bot: Bot, msg: Message| async move {
|
||||||
bot.send_dice(msg.chat.id).await?;
|
bot.send_dice(msg.chat.id).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
|
|
|
@ -113,26 +113,26 @@
|
||||||
//! type MyDialogue = Dialogue<State, InMemStorage<State>>;
|
//! type MyDialogue = Dialogue<State, InMemStorage<State>>;
|
||||||
//! type HandlerResult = Result<(), Box<dyn std::error::Error + Send + Sync>>;
|
//! type HandlerResult = Result<(), Box<dyn std::error::Error + Send + Sync>>;
|
||||||
//!
|
//!
|
||||||
//! async fn start(bot: Bot, msg: Message, dialogue: MyDialogue) -> HandlerResult {
|
//! async fn start(bot: Bot, dialogue: MyDialogue, msg: Message) -> HandlerResult {
|
||||||
//! todo!()
|
//! todo!()
|
||||||
//! }
|
//! }
|
||||||
//! async fn help(bot: Bot, msg: Message) -> HandlerResult {
|
//! async fn help(bot: Bot, msg: Message) -> HandlerResult {
|
||||||
//! todo!()
|
//! todo!()
|
||||||
//! }
|
//! }
|
||||||
//! async fn cancel(bot: Bot, msg: Message, dialogue: MyDialogue) -> HandlerResult {
|
//! async fn cancel(bot: Bot, dialogue: MyDialogue, msg: Message) -> HandlerResult {
|
||||||
//! todo!()
|
//! todo!()
|
||||||
//! }
|
//! }
|
||||||
//! async fn invalid_state(bot: Bot, msg: Message) -> HandlerResult {
|
//! async fn invalid_state(bot: Bot, msg: Message) -> HandlerResult {
|
||||||
//! todo!()
|
//! todo!()
|
||||||
//! }
|
//! }
|
||||||
//! async fn receive_full_name(bot: Bot, msg: Message, dialogue: MyDialogue) -> HandlerResult {
|
//! async fn receive_full_name(bot: Bot, dialogue: MyDialogue, msg: Message) -> HandlerResult {
|
||||||
//! todo!()
|
//! todo!()
|
||||||
//! }
|
//! }
|
||||||
//! async fn receive_product_selection(
|
//! async fn receive_product_selection(
|
||||||
//! bot: Bot,
|
//! bot: Bot,
|
||||||
//! q: CallbackQuery,
|
|
||||||
//! dialogue: MyDialogue,
|
//! dialogue: MyDialogue,
|
||||||
//! full_name: String,
|
//! full_name: String, // Available from `State::ReceiveProductChoice`.
|
||||||
|
//! q: CallbackQuery,
|
||||||
//! ) -> HandlerResult {
|
//! ) -> HandlerResult {
|
||||||
//! todo!()
|
//! todo!()
|
||||||
//! }
|
//! }
|
||||||
|
|
|
@ -39,9 +39,9 @@
|
||||||
//! # #[derive(Clone, Debug)] enum State { ReceiveLocation { full_name: String, age: u8 } }
|
//! # #[derive(Clone, Debug)] enum State { ReceiveLocation { full_name: String, age: u8 } }
|
||||||
//! async fn receive_age(
|
//! async fn receive_age(
|
||||||
//! bot: Bot,
|
//! bot: Bot,
|
||||||
//! msg: Message,
|
|
||||||
//! dialogue: MyDialogue,
|
//! dialogue: MyDialogue,
|
||||||
//! full_name: String, // Available from `State::ReceiveAge`.
|
//! full_name: String, // Available from `State::ReceiveAge`.
|
||||||
|
//! msg: Message,
|
||||||
//! ) -> HandlerResult {
|
//! ) -> HandlerResult {
|
||||||
//! match msg.text().map(|text| text.parse::<u8>()) {
|
//! match msg.text().map(|text| text.parse::<u8>()) {
|
||||||
//! Some(Ok(age)) => {
|
//! Some(Ok(age)) => {
|
||||||
|
@ -71,9 +71,9 @@
|
||||||
//! # #[derive(Clone, Debug)] enum State {}
|
//! # #[derive(Clone, Debug)] enum State {}
|
||||||
//! async fn receive_location(
|
//! async fn receive_location(
|
||||||
//! bot: Bot,
|
//! bot: Bot,
|
||||||
//! msg: Message,
|
|
||||||
//! dialogue: MyDialogue,
|
//! dialogue: MyDialogue,
|
||||||
//! (full_name, age): (String, u8), // Available from `State::ReceiveLocation`.
|
//! (full_name, age): (String, u8), // Available from `State::ReceiveLocation`.
|
||||||
|
//! msg: Message,
|
||||||
//! ) -> HandlerResult {
|
//! ) -> HandlerResult {
|
||||||
//! match msg.text() {
|
//! match msg.text() {
|
||||||
//! Some(location) => {
|
//! Some(location) => {
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
//!
|
//!
|
||||||
//! let bot = Bot::from_env();
|
//! let bot = Bot::from_env();
|
||||||
//!
|
//!
|
||||||
//! teloxide::repl(bot, |message: Message, bot: Bot| async move {
|
//! teloxide::repl(bot, |bot: Bot, msg: Message| async move {
|
||||||
//! bot.send_dice(message.chat.id).await?;
|
//! bot.send_dice(msg.chat.id).await?;
|
||||||
//! Ok(())
|
//! Ok(())
|
||||||
//! })
|
//! })
|
||||||
//! .await;
|
//! .await;
|
||||||
|
|
Loading…
Reference in a new issue