feat(controller): update notification logic to respect event_status_notify settings for trusted groups and admins
This commit is contained in:
@@ -247,15 +247,21 @@ func (q *QQController) SendStatusChange(change node.StatusChange) error {
|
|||||||
params := template.BuildParamsFromStatusChange(change)
|
params := template.BuildParamsFromStatusChange(change)
|
||||||
message := template.Render(cfg.ControllerMessage.ServerStatusChanged, params)
|
message := template.Render(cfg.ControllerMessage.ServerStatusChanged, params)
|
||||||
|
|
||||||
// Send to trusted groups.
|
// Only notify trusted groups and admins whose event_status_notify is true.
|
||||||
for _, groupID := range q.trustedGroupIDs() {
|
if uc := config.C_botUserConfig; uc != nil {
|
||||||
|
for groupID, opts := range uc.QQ.TrustedGroups {
|
||||||
|
if !opts.EventStatusNotify {
|
||||||
|
continue
|
||||||
|
}
|
||||||
q.sendGroupMessage(groupID, message)
|
q.sendGroupMessage(groupID, message)
|
||||||
}
|
}
|
||||||
|
for adminID, opts := range uc.QQ.Admins {
|
||||||
// Send to admins via private message.
|
if !opts.EventStatusNotify {
|
||||||
for _, adminID := range q.adminIDs() {
|
continue
|
||||||
|
}
|
||||||
q.sendPrivateMessage(adminID, message)
|
q.sendPrivateMessage(adminID, message)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,7 +249,21 @@ func (t *TelegramController) SendStatusChange(change node.StatusChange) error {
|
|||||||
params := template.BuildParamsFromStatusChange(change)
|
params := template.BuildParamsFromStatusChange(change)
|
||||||
message := template.Render(cfg.ControllerMessage.ServerStatusChanged, params)
|
message := template.Render(cfg.ControllerMessage.ServerStatusChanged, params)
|
||||||
|
|
||||||
t.sendToGroupsAndAdmins(message)
|
// Only notify trusted groups and admins whose event_status_notify is true.
|
||||||
|
if uc := config.C_botUserConfig; uc != nil {
|
||||||
|
for groupID, opts := range uc.Telegram.TrustedGroups {
|
||||||
|
if !opts.EventStatusNotify {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
t.sendGroupMessage(groupID, message)
|
||||||
|
}
|
||||||
|
for admin, opts := range uc.Telegram.Admins {
|
||||||
|
if !opts.EventStatusNotify {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
t.sendAdminMessage(admin, message)
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user