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:
9 files changed
+307
-10
No files matched your search
@@ -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';
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user