diff --git a/Cargo.toml b/Cargo.toml index 8506996..7c029d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bing-dict-telegram-bot" description = "A Telegram bot uses Bing Dictionary to translate words and phrases from Chinese to English or English to Chinese" -version = "0.5.0" +version = "0.5.1" authors = ["EAimTY "] edition = "2021" readme = "README.md" diff --git a/src/handler/command.rs b/src/handler/command.rs index 2cce95e..78d756f 100644 --- a/src/handler/command.rs +++ b/src/handler/command.rs @@ -7,6 +7,7 @@ use tgbot::{ impl Handler { pub async fn handle_command(context: &Context, command: Command) -> Result<(), HandlerError> { let chat_id = command.get_message().get_chat_id(); + let message_id = command.get_message().id; #[derive(PartialEq)] enum ArgPos { @@ -69,7 +70,9 @@ impl Handler { context .api - .execute(SendMessage::new(chat_id, result)) + .execute( + SendMessage::new(chat_id, result).reply_to_message_id(message_id), + ) .await?; } } @@ -85,7 +88,11 @@ impl Handler { context .api - .execute(SendMessage::new(chat_id, result).parse_mode(ParseMode::Html)) + .execute( + SendMessage::new(chat_id, result) + .parse_mode(ParseMode::Html) + .reply_to_message_id(message_id), + ) .await?; } @@ -106,7 +113,11 @@ Use /help to get more information. context .api - .execute(SendMessage::new(chat_id, result).parse_mode(ParseMode::Html)) + .execute( + SendMessage::new(chat_id, result) + .parse_mode(ParseMode::Html) + .reply_to_message_id(message_id), + ) .await?; } @@ -121,7 +132,7 @@ https://github.com/EAimTY/bing-dict-telegram-bot context .api - .execute(SendMessage::new(chat_id, result)) + .execute(SendMessage::new(chat_id, result).reply_to_message_id(message_id)) .await?; } @@ -140,7 +151,11 @@ When you need a translate, just enter {} word / phrase in any chat and se context .api - .execute(SendMessage::new(chat_id, result).parse_mode(ParseMode::Html)) + .execute( + SendMessage::new(chat_id, result) + .parse_mode(ParseMode::Html) + .reply_to_message_id(message_id), + ) .await?; } diff --git a/src/handler/message.rs b/src/handler/message.rs index c721685..6925a4b 100644 --- a/src/handler/message.rs +++ b/src/handler/message.rs @@ -7,6 +7,7 @@ use tgbot::{ impl Handler { pub async fn handle_message(context: &Context, message: Message) -> Result<(), HandlerError> { let chat_id = message.get_chat_id(); + let message_id = message.id; let message_trigger = context.message_trigger.read().await; @@ -37,7 +38,7 @@ impl Handler { context .api - .execute(SendMessage::new(chat_id, result)) + .execute(SendMessage::new(chat_id, result).reply_to_message_id(message_id)) .await?; } }