mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 21:10:23 +00:00
refactor: groupNotifies
This commit is contained in:
@@ -2,7 +2,6 @@ import BaseAction from '../BaseAction';
|
||||
import { GroupRequestOperateTypes } from '@/core/entities';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQGroupApi } from '@/core/apis/group';
|
||||
import { groupNotifies } from '@/core/data';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
const SchemaData = {
|
||||
@@ -23,11 +22,7 @@ export default class SetGroupAddRequest extends BaseAction<Payload, null> {
|
||||
protected async _handle(payload: Payload): Promise<null> {
|
||||
const flag = payload.flag.toString();
|
||||
const approve = payload.approve?.toString() !== 'false';
|
||||
const notify = groupNotifies[flag];
|
||||
if (!notify) {
|
||||
throw `${flag}对应的加群通知不存在`;
|
||||
}
|
||||
await NTQQGroupApi.handleGroupRequest(notify,
|
||||
await NTQQGroupApi.handleGroupRequest(flag,
|
||||
approve ? GroupRequestOperateTypes.approve : GroupRequestOperateTypes.reject,
|
||||
payload.reason
|
||||
);
|
||||
|
||||
@@ -19,7 +19,7 @@ import { OB11Config, ob11Config } from '@/onebot11/config';
|
||||
import { httpHeart, ob11HTTPServer } from '@/onebot11/server/http';
|
||||
import { ob11WebsocketServer } from '@/onebot11/server/ws/WebsocketServer';
|
||||
import { ob11ReverseWebsockets } from '@/onebot11/server/ws/ReverseWebsocket';
|
||||
import { getGroup, getGroupMember, groupNotifies, selfInfo, tempGroupCodeMap } from '@/core/data';
|
||||
import { getGroup, getGroupMember, selfInfo, tempGroupCodeMap } from '@/core/data';
|
||||
import { dbUtil } from '@/common/utils/db';
|
||||
import { BuddyListener, GroupListener, NodeIKernelBuddyListener } from '@/core/listeners';
|
||||
import { OB11FriendRequestEvent } from '@/onebot11/event/request/OB11FriendRequest';
|
||||
@@ -408,13 +408,8 @@ export class NapCatOnebot11 {
|
||||
if (notifyTime < this.bootTime) {
|
||||
continue;
|
||||
}
|
||||
const flag = notify.group.groupCode + '|' + notify.seq;
|
||||
const existNotify = groupNotifies[flag];
|
||||
if (existNotify) {
|
||||
continue;
|
||||
}
|
||||
const flag = notify.group.groupCode + '|' + notify.seq + '|' + notify.type;
|
||||
logDebug('收到群通知', notify);
|
||||
groupNotifies[flag] = notify;
|
||||
// let member2: GroupMember;
|
||||
// if (notify.user2.uid) {
|
||||
// member2 = await getGroupMember(notify.group.groupCode, null, notify.user2.uid);
|
||||
|
||||
@@ -12,7 +12,7 @@ import { OB11FriendRequestEvent } from '../event/request/OB11FriendRequest';
|
||||
import { OB11GroupRequestEvent } from '../event/request/OB11GroupRequest';
|
||||
import { isNull } from '@/common/utils/helper';
|
||||
import { dbUtil } from '@/common/utils/db';
|
||||
import { getGroup, groupNotifies, selfInfo } from '@/core/data';
|
||||
import { getGroup, selfInfo } from '@/core/data';
|
||||
import { NTQQFriendApi, NTQQGroupApi, NTQQUserApi } from '@/core/apis';
|
||||
import createSendElements from '../action/msg/SendMsg/create-send-elements';
|
||||
|
||||
@@ -168,7 +168,7 @@ async function handleMsg(msg: OB11Message, quickAction: QuickAction) {
|
||||
async function handleGroupRequest(request: OB11GroupRequestEvent, quickAction: QuickActionGroupRequest) {
|
||||
if (!isNull(quickAction.approve)) {
|
||||
NTQQGroupApi.handleGroupRequest(
|
||||
groupNotifies[request.flag],
|
||||
request.flag,
|
||||
quickAction.approve ? GroupRequestOperateTypes.approve : GroupRequestOperateTypes.reject,
|
||||
quickAction.reason,
|
||||
).then().catch(logError);
|
||||
|
||||
Reference in New Issue
Block a user