This commit is contained in:
2026-05-31 13:36:33 +05:00
parent 19f6475573
commit 94d47092af
7 changed files with 208 additions and 0 deletions

35
CurrencyAnalyzer.java Normal file
View File

@@ -0,0 +1,35 @@
public class CurrencyAnalyzer {
private static double last_value = -1;
public static void analyze(double current) {
if (last_value == -1) {
last_value = current;
String start_msg = "<b>Мониторинг курса USD запущен</b>\n" +
"Текущий курс: <b>" + current + "</b> ₽";
TelegramNotifier.sendMessage(start_msg);
System.out.println("Начальное значение USD: " + current);
return;
}
String msg = "";
if (current > last_value) {
msg = "Курс доллара <b>вырос ↑</b>";
} else if (current < last_value) {
msg = "Курс доллара <b>упал ↓</b>";
} else {
return;
}
String telegram_msg = msg + "\n" +
"Было: <b>" + last_value + "</b> ₽\n" +
"Стало: <b>" + current + "</b> ₽";
TelegramNotifier.sendMessage(telegram_msg);
System.out.println(msg.replace("<b>", "").replace("</b>", "") +
" (было " + last_value + ", стало " + current + ")");
last_value = current;
}
}