Skip to content
This repository has been archived by the owner on Jun 17, 2023. It is now read-only.

Commit

Permalink
reply to the original message
Browse files Browse the repository at this point in the history
  • Loading branch information
EAimTY committed Nov 5, 2021
1 parent 21a8888 commit 92d8a58
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <ea.imty@gmail.com>"]
edition = "2021"
readme = "README.md"
Expand Down
25 changes: 20 additions & 5 deletions src/handler/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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?;
}
}
Expand All @@ -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?;
}

Expand All @@ -106,7 +113,11 @@ Use <i>/help</i> 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?;
}

Expand All @@ -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?;
}

Expand All @@ -140,7 +151,11 @@ When you need a translate, just enter <i>{} word / phrase</i> 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?;
}

Expand Down
3 changes: 2 additions & 1 deletion src/handler/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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?;
}
}
Expand Down

0 comments on commit 92d8a58

Please sign in to comment.