From 2bf677ebe32fad0ffc9429a87dfc22977829a001 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Sun, 4 Jan 2026 22:50:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B5=E6=8A=A5=E6=96=B0=E5=A2=9E=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../other/app/service/TelegramMonitorService.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/TelegramMonitorService.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/TelegramMonitorService.java index 4ad2172d..8cc04506 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/TelegramMonitorService.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/TelegramMonitorService.java @@ -44,6 +44,11 @@ public class TelegramMonitorService { @PostConstruct public void init() { + if (telegramProperties.getBot() == null || telegramProperties.getBot().getToken() == null) { + log.warn("Telegram 配置未启用,跳过初始化"); + return; + } + String botToken = telegramProperties.getBot().getToken(); List chatIds = telegramProperties.getMonitor().getChatIds(); int alertLimitSeconds = telegramProperties.getMonitor().getAlertLimitSeconds(); @@ -191,7 +196,16 @@ public class TelegramMonitorService { * 发送到所有配置的 chatId */ private void sendToAllChats(String message) { + if (telegramClient == null) { + log.warn("Telegram 未初始化,跳过发送"); + return; + } + List chatIds = telegramProperties.getMonitor().getChatIds(); + if (chatIds == null || chatIds.isEmpty()) { + log.warn("Telegram chatIds 未配置,跳过发送"); + return; + } for (String chatId : chatIds) { sendTextToChat(chatId, message); }