Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
lucky committed Nov 22, 2024
1 parent 57767ef commit 2c774f7
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/bot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ async fn src_repl(
db: Arc<Database>,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let cached = db.get_cache_src(src, rate_type).await;
let mut s = match cached {
let s = match cached {
Some(s) => s,
None => {
log::debug!("empty cache src");
Expand All @@ -382,13 +382,12 @@ async fn src_repl(
if !s.is_empty() {
s = html::code_inline(&s);
db.set_cache_src(src, rate_type, s.clone()).await;
} else {
s = DUNNO.into()
}
s
}
};
if s.is_empty() {
s = DUNNO.into()
}
bot.send_message(msg.chat.id, s).await?;
Ok(())
}
Expand All @@ -411,7 +410,7 @@ async fn conv_repl(
let cached = db
.get_cache_conv(from.clone(), to.clone(), rate_type, is_inv)
.await;
let mut s = match cached {
let s = match cached {
Some(s) => s,
None => {
log::debug!("empty cache conv");
Expand All @@ -421,13 +420,12 @@ async fn conv_repl(
s = html::code_block(&s);
db.set_cache_conv(from.clone(), to.clone(), rate_type, is_inv, s.clone())
.await;
} else {
s = DUNNO.into()
}
s
}
};
if s.is_empty() {
s = DUNNO.into()
}
bot.send_message(msg.chat.id, s).await?;
std::mem::swap(&mut from, &mut to);
}
Expand Down

0 comments on commit 2c774f7

Please sign in to comment.