mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
feat: emit group/request,invite
This commit is contained in:
parent
426e26b8b9
commit
63f37d971c
@ -5,9 +5,11 @@ import {
|
|||||||
FriendRequest,
|
FriendRequest,
|
||||||
GrayTipElement,
|
GrayTipElement,
|
||||||
GroupNotify,
|
GroupNotify,
|
||||||
|
GroupNotifyMsgStatus,
|
||||||
GroupNotifyMsgType,
|
GroupNotifyMsgType,
|
||||||
RawMessage,
|
RawMessage,
|
||||||
SendStatusType, TipGroupElement,
|
SendStatusType,
|
||||||
|
TipGroupElement,
|
||||||
} from '@/core/entities';
|
} from '@/core/entities';
|
||||||
import { NodeIKernelBuddyListener, NodeIKernelGroupListener, NodeIKernelMsgListener } from '@/core/listeners';
|
import { NodeIKernelBuddyListener, NodeIKernelGroupListener, NodeIKernelMsgListener } from '@/core/listeners';
|
||||||
import EventEmitter from 'node:events';
|
import EventEmitter from 'node:events';
|
||||||
@ -37,7 +39,11 @@ type NapCatInternalEvents = {
|
|||||||
'buddy/input-status': (data: Parameters<NodeIKernelMsgListener['onInputStatusPush']>[0]) => PromiseLike<void>;
|
'buddy/input-status': (data: Parameters<NodeIKernelMsgListener['onInputStatusPush']>[0]) => PromiseLike<void>;
|
||||||
|
|
||||||
|
|
||||||
'group/request': (request: GroupNotify) => PromiseLike<void>;
|
'group/request': (groupCode: string, requestUin: string, words: string,
|
||||||
|
xGroupNotify: GroupNotify) => PromiseLike<void>;
|
||||||
|
|
||||||
|
'group/invite': (groupCode: string, invitorUin: string,
|
||||||
|
xGroupNotify: GroupNotify) => PromiseLike<void>;
|
||||||
|
|
||||||
'group/admin': (groupCode: string, targetUin: string, operation: 'set' | 'unset',
|
'group/admin': (groupCode: string, targetUin: string, operation: 'set' | 'unset',
|
||||||
// If it comes from onGroupNotifiesUpdated
|
// If it comes from onGroupNotifiesUpdated
|
||||||
@ -234,6 +240,7 @@ export class NapCatEventChannel extends
|
|||||||
operatorUin,
|
operatorUin,
|
||||||
notify
|
notify
|
||||||
);
|
);
|
||||||
|
continue;
|
||||||
} else {
|
} else {
|
||||||
// No operator, indicates that the member leaves
|
// No operator, indicates that the member leaves
|
||||||
this.emit(
|
this.emit(
|
||||||
@ -242,11 +249,52 @@ export class NapCatEventChannel extends
|
|||||||
leftMemberUin,
|
leftMemberUin,
|
||||||
notify
|
notify
|
||||||
);
|
);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.core.context.logger.logError('处理退群消息失败', e);
|
this.core.context.logger.logError('处理退群消息失败', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (
|
||||||
|
notify.type === GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS &&
|
||||||
|
notify.status === GroupNotifyMsgStatus.KUNHANDLE
|
||||||
|
) {
|
||||||
|
this.core.context.logger.logDebug('入群请求', notify);
|
||||||
|
const requesterUin = await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid);
|
||||||
|
this.emit(
|
||||||
|
'group/request',
|
||||||
|
notify.group.groupCode,
|
||||||
|
requesterUin,
|
||||||
|
notify.postscript,
|
||||||
|
notify
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
this.core.context.logger.logError('处理入群请求失败', e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Todo: unstable, may need to be in sync with main branch
|
||||||
|
if (
|
||||||
|
notify.type == GroupNotifyMsgType.INVITED_BY_MEMBER &&
|
||||||
|
notify.status == GroupNotifyMsgStatus.KUNHANDLE
|
||||||
|
) {
|
||||||
|
this.core.context.logger.logDebug('入群邀请', notify);
|
||||||
|
const requesterUin = await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid);
|
||||||
|
this.emit(
|
||||||
|
'group/invite',
|
||||||
|
notify.group.groupCode,
|
||||||
|
requesterUin,
|
||||||
|
notify
|
||||||
|
);
|
||||||
|
// continue;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
this.core.context.logger.logError('处理入群邀请失败', e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user