feat(onebot): emit bot_status on account session edges

Give downstream bots a notice when an account comes up or goes down, so they can handle their own alerts. Operator notification channels are unchanged.
This commit is contained in:
DrSmoothl committed 2026-09-16 17:04:06 +08:00
1 parent f2d58d2f79
commit ad36d47cf0
9 files changed
+307 -10

No files matched your search

+8
View File
@@ -1,4 +1,5 @@
import type {
OneBotBotStatusEvent,
OneBotGroupMessageEvent,
OneBotMessageEvent,
OneBotMetaEvent,
@@ -26,6 +27,13 @@ export function isNoticeEvent(event: SnowLumaEvent): event is OneBotNoticeEvent
return event.post_type === 'notice' && typeof event.notice_type === 'string';
}
export function isBotStatusEvent(event: SnowLumaEvent): event is OneBotBotStatusEvent {
return isNoticeEvent(event)
&& event.notice_type === 'bot_status'
&& (event.sub_type === 'online' || event.sub_type === 'offline')
&& typeof event.user_id === 'number';
}
export function isRequestEvent(event: SnowLumaEvent): event is OneBotRequestEvent {
return event.post_type === 'request' && typeof event.request_type === 'string' && typeof event.flag === 'string';
}