26 包 monorepo(TS 全源码): - snowcat-core: NT 内核 API 封装 + listener(含 9.9.37 六回调适配)+ Packet 发包 - snowcat-onebot: OneBot v11 全动作 + MCP Streamable HTTP 适配器 + 稳定线 - snowcat-webui-frontend/backend: 雪猫控制台(React+HeroUI) - snowcat-shell: 单文件 bundle 出口(vite inlineDynamicImports) - snowcat-native: napi2native / MoeHoo / ffmpeg / pty 运行时 - 56 项 SnowLuma 独门动作移植(qzone 全家桶/群相册/装扮/闪照/收藏) - 工具件: 解包器/启动器/便携制作器/doctor GitHub 关联已全量指向 DandanLLab/SnowCatQQ
67 lines
2.6 KiB
TypeScript
67 lines
2.6 KiB
TypeScript
import { OneBotAction } from '@/snowcat-onebot/action/OneBotAction';
|
|
import { GroupNotify, NTGroupRequestOperateTypes } from 'snowcat-core/types';
|
|
import { ActionName } from '@/snowcat-onebot/action/router';
|
|
import { Static, Type } from '@sinclair/typebox';
|
|
|
|
import { GroupActionsExamples } from '../example/GroupActionsExamples';
|
|
|
|
const PayloadSchema = Type.Object({
|
|
flag: Type.String({ description: '请求flag' }),
|
|
approve: Type.Optional(Type.Union([Type.Boolean(), Type.String()], { description: '是否同意' })),
|
|
reason: Type.Optional(Type.Union([Type.String({ default: ' ' }), Type.Null()], { description: '拒绝理由' })),
|
|
count: Type.Optional(Type.Number({ default: 100, description: '搜索通知数量' })),
|
|
});
|
|
|
|
type PayloadType = Static<typeof PayloadSchema>;
|
|
|
|
const ReturnSchema = Type.Null({ description: '操作结果' });
|
|
|
|
type ReturnType = Static<typeof ReturnSchema>;
|
|
|
|
export default class SetGroupAddRequest extends OneBotAction<PayloadType, ReturnType> {
|
|
override actionName = ActionName.SetGroupAddRequest;
|
|
override payloadSchema = PayloadSchema;
|
|
override returnSchema = ReturnSchema;
|
|
override actionSummary = '处理加群请求';
|
|
override actionDescription = '同意或拒绝加群请求或邀请';
|
|
override actionTags = ['群组接口'];
|
|
override payloadExample = GroupActionsExamples.SetGroupAddRequest.payload;
|
|
override returnExample = GroupActionsExamples.SetGroupAddRequest.response;
|
|
|
|
async _handle (payload: PayloadType): Promise<null> {
|
|
const flag = payload.flag.toString();
|
|
const approve = payload.approve?.toString() !== 'false';
|
|
const reason = payload.reason ?? ' ';
|
|
const count = payload.count;
|
|
const invite_notify = this.obContext.apis.MsgApi.notifyGroupInvite.get(flag);
|
|
const { doubt, notify } = invite_notify
|
|
? {
|
|
doubt: false,
|
|
notify: invite_notify,
|
|
}
|
|
: await this.findNotify(flag, count);
|
|
if (!notify) {
|
|
throw new Error('No such request');
|
|
}
|
|
await this.core.apis.GroupApi.handleGroupRequest(
|
|
doubt,
|
|
notify,
|
|
approve ? NTGroupRequestOperateTypes.KAGREE : NTGroupRequestOperateTypes.KREFUSE,
|
|
reason
|
|
);
|
|
return null;
|
|
}
|
|
|
|
private async findNotify (flag: string, count: number = 100): Promise<{
|
|
doubt: boolean,
|
|
notify: GroupNotify | undefined;
|
|
}> {
|
|
let notify = (await this.core.apis.GroupApi.getSingleScreenNotifies(false, count)).find(e => e.seq === flag);
|
|
if (!notify) {
|
|
notify = (await this.core.apis.GroupApi.getSingleScreenNotifies(true, count)).find(e => e.seq === flag);
|
|
return { doubt: true, notify };
|
|
}
|
|
return { doubt: false, notify };
|
|
}
|
|
}
|