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

Commit

Permalink
update dep bing-dict to version 0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
EAimTY committed Nov 10, 2021
1 parent 92d8a58 commit 491d896
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
[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.1"
version = "0.5.2"
authors = ["EAimTY <ea.imty@gmail.com>"]
edition = "2021"
readme = "README.md"
license = "GPL-3.0-or-later"
repository = "https://github.com/EAimTY/bing-dict-telegram-bot"

[dependencies]
bing-dict = "0.1"
bing-dict = "0.2"
futures-util = "0.3"
getopts = "0.2"
tgbot = "0.14"
thiserror = "1.0"
tinyset = "0.4"
tokio = { version = "1.11", features = ["rt-multi-thread", "macros"] }
tokio = { version = "1.13", features = ["rt-multi-thread", "macros"] }

[profile.release]
lto = true
Expand Down
7 changes: 4 additions & 3 deletions src/handler/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ impl Handler {

if let Some(input) = input {
let result = if !input.is_empty() {
bing_dict::translate(input)
.await?
.unwrap_or_else(|| String::from("No paraphrase found"))
bing_dict::translate(input).await?.map_or_else(
|| String::from("No paraphrase found"),
|paraphrase| paraphrase.to_string(),
)
} else {
String::from("No input")
};
Expand Down
7 changes: 4 additions & 3 deletions src/handler/inline_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ impl Handler {
let InlineQuery { id, query, .. } = inline_query;

let inline_query_result = if !query.is_empty() {
let translate_result = bing_dict::translate(&query)
.await?
.unwrap_or_else(|| String::from("No paraphrase found"));
let translate_result = bing_dict::translate(&query).await?.map_or_else(
|| String::from("No paraphrase found"),
|paraphrase| paraphrase.to_string(),
);

vec![InlineQueryResult::Article(InlineQueryResultArticle::new(
query,
Expand Down
7 changes: 4 additions & 3 deletions src/handler/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ impl Handler {

if let Some(input) = input {
let result = if !input.is_empty() {
bing_dict::translate(input)
.await?
.unwrap_or_else(|| String::from("No paraphrase found"))
bing_dict::translate(input).await?.map_or_else(
|| String::from("No paraphrase found"),
|paraphrase| paraphrase.to_string(),
)
} else {
String::from("No input")
};
Expand Down

0 comments on commit 491d896

Please sign in to comment.