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,5 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
isBotStatusEvent,
|
||||
isGroupMessageEvent,
|
||||
isMessageEvent,
|
||||
isMetaEvent,
|
||||
@@ -248,6 +249,34 @@ describe('isNoticeEvent', () => {
|
||||
expect(isNoticeEvent(nulled)).toBe(false);
|
||||
});
|
||||
|
||||
it('accepts bot_status notices and rejects incomplete ones', () => {
|
||||
expect(isBotStatusEvent({
|
||||
time: 19,
|
||||
self_id: 10000,
|
||||
post_type: 'notice',
|
||||
notice_type: 'bot_status',
|
||||
sub_type: 'online',
|
||||
user_id: 10000,
|
||||
})).toBe(true);
|
||||
expect(isBotStatusEvent({
|
||||
time: 20,
|
||||
self_id: 10000,
|
||||
post_type: 'notice',
|
||||
notice_type: 'bot_status',
|
||||
sub_type: 'offline',
|
||||
user_id: 10000,
|
||||
})).toBe(true);
|
||||
expect(isBotStatusEvent(NOTICE)).toBe(false);
|
||||
expect(isBotStatusEvent({
|
||||
time: 21,
|
||||
self_id: 10000,
|
||||
post_type: 'notice',
|
||||
notice_type: 'bot_status',
|
||||
sub_type: 'flap',
|
||||
user_id: 10000,
|
||||
})).toBe(false);
|
||||
});
|
||||
|
||||
it('rejects other post types', () => {
|
||||
expect(isNoticeEvent(PRIVATE_MESSAGE)).toBe(false);
|
||||
expect(isNoticeEvent(REQUEST)).toBe(false);
|
||||
|
||||
Reference in new issue
Block a user