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 9308d73 commit 44cf835
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/bot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ async fn start_repl(
cfg: Arc<Config>,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
if value.is_empty() {
bot.send_message(msg.chat.id, &cfg.bot.welcome_msg).await?;
bot.send_message(msg.chat.id, html::escape(&cfg.bot.welcome_msg))
.await?;
return Ok(());
}
let mut value = value.clone();
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct Webhook {

impl Config {
pub fn load() -> anyhow::Result<Arc<Self>> {
let cfg = toml::from_str(fs::read_to_string(env::var(ENV_CONFIG)?)?.as_str())?;
let cfg = toml::from_str(&fs::read_to_string(env::var(ENV_CONFIG)?)?)?;
Ok(Arc::new(cfg))
}
}
2 changes: 1 addition & 1 deletion src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ where
.get(
config
.rates_url()
.replace("%d", (rate_type as u8).to_string().as_str()),
.replace("%d", &(rate_type as u8).to_string()),
)
.header(reqwest::header::USER_AGENT, USER_AGENT)
.send()
Expand Down
2 changes: 1 addition & 1 deletion src/source/unionpay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub async fn collect(client: &reqwest::Client, config: &Config) -> anyhow::Resul
let mut config = config.clone();
config.rates_url = config
.rates_url
.replace("%s", date.format("%Y%m%d").to_string().as_str());
.replace("%s", &date.format("%Y%m%d").to_string());
let resp: Response = get_json(client, &config).await?;
let from = Currency::usd();
let to = Currency::rub();
Expand Down

0 comments on commit 44cf835

Please sign in to comment.