Upload files to "/"
This commit is contained in:
39
CurrencyAnalyzer.java
Normal file
39
CurrencyAnalyzer.java
Normal file
@@ -0,0 +1,39 @@
|
||||
public class CurrencyAnalyzer {
|
||||
|
||||
private static double lastValue = -1;
|
||||
|
||||
public static void analyze(double current) {
|
||||
if (lastValue == -1) {
|
||||
lastValue = current;
|
||||
|
||||
// Уведомление при запуске
|
||||
String startMsg = "✅ <b>Мониторинг курса USD запущен</b>\n" +
|
||||
"Текущий курс: <b>" + current + "</b> ₽";
|
||||
TelegramNotifier.sendMessage(startMsg);
|
||||
|
||||
System.out.println("Начальное значение USD: " + current);
|
||||
return;
|
||||
}
|
||||
|
||||
String changeMsg = "";
|
||||
if (current > lastValue) {
|
||||
changeMsg = "📈 Курс доллара <b>вырос ↑</b>";
|
||||
} else if (current < lastValue) {
|
||||
changeMsg = "📉 Курс доллара <b>упал ↓</b>";
|
||||
} else {
|
||||
return; // без изменений — не спамим
|
||||
}
|
||||
|
||||
// Уведомление в Telegram
|
||||
String telegramMsg = changeMsg + "\n" +
|
||||
"Было: <b>" + lastValue + "</b> ₽\n" +
|
||||
"Стало: <b>" + current + "</b> ₽";
|
||||
TelegramNotifier.sendMessage(telegramMsg);
|
||||
|
||||
// Вывод в консоль (чистый текст)
|
||||
System.out.println(changeMsg.replace("<b>", "").replace("</b>", "") +
|
||||
" (было " + lastValue + ", стало " + current + ")");
|
||||
|
||||
lastValue = current;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user