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

38
Main.java Normal file
View File

@@ -0,0 +1,38 @@
public class Main {
public static void main(String[] args) {
String bot_token = System.getenv("BOT_TOKEN");
String chat_id = System.getenv("CHAT_ID");
if (bot_token == null || bot_token.isBlank() || chat_id == null || chat_id.isBlank()) {
System.err.println("Не найдены environment BOT_TOKEN и CHAT_ID");
return;
}
TelegramNotifier.init(bot_token, chat_id);
System.out.println("Telegram-уведомления работают.");
String url = "https://cbr.ru/currency_base/daily/";
while (true) {
try {
String html = WebLoader.loadPage(url);
double usd = CurrencyParser.parseUSD(html);
if (usd != -1) {
System.out.println("USD: " + usd);
CsvWriter.write(usd);
CurrencyAnalyzer.analyze(usd);
} else {
System.err.println("Не удалось спарсить курс USD");
}
Thread.sleep(60 * 1000);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}