mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Cargo fmt fix
This commit is contained in:
parent
87c8557e36
commit
ab87451b62
1 changed files with 9 additions and 16 deletions
|
@ -22,10 +22,10 @@ pub enum State {
|
||||||
#[command(rename_rule = "lowercase")]
|
#[command(rename_rule = "lowercase")]
|
||||||
pub enum StartCommand {
|
pub enum StartCommand {
|
||||||
#[command()]
|
#[command()]
|
||||||
Start(String), // Because deep linking (links like https://t.me/some_bot?start=123456789) is the
|
Start(String), /* Because deep linking (links like https://t.me/some_bot?start=123456789) is the
|
||||||
// same as sending "/start 123456789", we can treat it as just an argument to a command
|
* same as sending "/start 123456789", we can treat it as just an argument to a command
|
||||||
//
|
*
|
||||||
// https://core.telegram.org/bots/features#deep-linking
|
* https://core.telegram.org/bots/features#deep-linking */
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
@ -61,7 +61,7 @@ pub async fn start(
|
||||||
cmd: StartCommand,
|
cmd: StartCommand,
|
||||||
me: Me,
|
me: Me,
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
// If you have multiple commands, this will need to become a match, not just a let
|
// If you have multiple commands, this will need to become a match
|
||||||
let StartCommand::Start(arg) = cmd;
|
let StartCommand::Start(arg) = cmd;
|
||||||
|
|
||||||
if arg.is_empty() {
|
if arg.is_empty() {
|
||||||
|
@ -103,10 +103,7 @@ pub async fn send_message(
|
||||||
Some(text) => {
|
Some(text) => {
|
||||||
// Trying to send a message to the user
|
// Trying to send a message to the user
|
||||||
let sent_result = bot
|
let sent_result = bot
|
||||||
.send_message(
|
.send_message(ChatId(id), format!("You have a new message!\n\n<i>{text}</i>"))
|
||||||
ChatId(id),
|
|
||||||
format!("You have a new message!\n\n<i>{text}</i>"),
|
|
||||||
)
|
|
||||||
.parse_mode(teloxide::types::ParseMode::Html)
|
.parse_mode(teloxide::types::ParseMode::Html)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
@ -122,17 +119,13 @@ pub async fn send_message(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
} else {
|
} else {
|
||||||
bot.send_message(
|
bot.send_message(msg.chat.id, "Error sending message! Maybe user blocked the bot?")
|
||||||
msg.chat.id,
|
.await?;
|
||||||
"Error sending message! Maybe user blocked the bot?",
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
}
|
}
|
||||||
dialogue.exit().await?;
|
dialogue.exit().await?;
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
bot.send_message(msg.chat.id, "This bot can send only text.")
|
bot.send_message(msg.chat.id, "This bot can send only text.").await?;
|
||||||
.await?;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue