电报新增配置开关
This commit is contained in:
parent
f4c521e9f0
commit
2bf677ebe3
@ -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<String> 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<String> chatIds = telegramProperties.getMonitor().getChatIds();
|
||||
if (chatIds == null || chatIds.isEmpty()) {
|
||||
log.warn("Telegram chatIds 未配置,跳过发送");
|
||||
return;
|
||||
}
|
||||
for (String chatId : chatIds) {
|
||||
sendTextToChat(chatId, message);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user