From 219005a03e266f3802189cc0ef1c7c5b738c2a58 Mon Sep 17 00:00:00 2001 From: Pavel Kirilin <win10@list.ru> Date: Wed, 22 Feb 2023 08:18:01 +0000 Subject: [PATCH] Added .rl, fixed some messages, removed liveness probe. --- src/bot/handlers/basic/currency_converter.rs | 10 +++++++++- src/bot/handlers/fun/rotator.rs | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/bot/handlers/basic/currency_converter.rs b/src/bot/handlers/basic/currency_converter.rs index 57f854c..870beba 100644 --- a/src/bot/handlers/basic/currency_converter.rs +++ b/src/bot/handlers/basic/currency_converter.rs @@ -146,12 +146,20 @@ impl Handler for CurrencyConverter { .or(cur_name) else{ continue; }; + let Some(nominal) = valutes + .get(cur_name) + .and_then(|info| info.get("Nominal")) + .map(ToString::to_string) + .and_then(|value| value.as_str().parse::<f64>().ok()) + else{ + continue; + }; let calculated = valutes .get(cur_name) .and_then(|info| info.get("Value")) .map(ToString::to_string) .and_then(|value| value.as_str().parse::<f64>().ok()) - .map(|multiplier| multiplier * num_value); + .map(|multiplier| multiplier * num_value / nominal); if let Some(value) = calculated { calucates.push(format!( "<pre>{num_value} {cur_name} = {value:.2} RUB</pre><br>" diff --git a/src/bot/handlers/fun/rotator.rs b/src/bot/handlers/fun/rotator.rs index db4511c..4bfbf79 100644 --- a/src/bot/handlers/fun/rotator.rs +++ b/src/bot/handlers/fun/rotator.rs @@ -25,7 +25,7 @@ async fn rotator(replied_message: Message, text: String) { .collect::<String>(); skip += 1; if skip == rotated.len() { - skip = 0; + skip = 1; } replied_message.edit(rotated).await.ok(); current = std::time::SystemTime::now(); -- GitLab