mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
fix: 提高兼容性
This commit is contained in:
@@ -22,7 +22,7 @@ export default class SetGroupAddRequest extends BaseAction<Payload, null> {
|
|||||||
PayloadSchema = SchemaData;
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
const flag = payload.flag.toString();
|
const flag = payload.flag.toString();
|
||||||
const approve = payload.approve?.toString() === 'true';
|
const approve = payload.approve?.toString() !== 'false';
|
||||||
const notify = groupNotifies[flag];
|
const notify = groupNotifies[flag];
|
||||||
if (!notify) {
|
if (!notify) {
|
||||||
throw `${flag}对应的加群通知不存在`;
|
throw `${flag}对应的加群通知不存在`;
|
||||||
|
@@ -12,7 +12,7 @@ const SchemaData = {
|
|||||||
user_id: { type: [ 'number' , 'string' ] },
|
user_id: { type: [ 'number' , 'string' ] },
|
||||||
enable: { type: 'boolean' }
|
enable: { type: 'boolean' }
|
||||||
},
|
},
|
||||||
required: ['group_id', 'user_id', 'enable']
|
required: ['group_id', 'user_id']
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
@@ -23,7 +23,7 @@ export default class SetGroupAdmin extends BaseAction<Payload, null> {
|
|||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
const member = await getGroupMember(payload.group_id, payload.user_id);
|
const member = await getGroupMember(payload.group_id, payload.user_id);
|
||||||
// 已经前置验证类型
|
// 已经前置验证类型
|
||||||
const enable = payload.enable.toString() === 'true';
|
const enable = payload.enable?.toString() !== 'false';
|
||||||
if (!member) {
|
if (!member) {
|
||||||
throw `群成员${payload.user_id}不存在`;
|
throw `群成员${payload.user_id}不存在`;
|
||||||
}
|
}
|
||||||
|
@@ -7,9 +7,9 @@ const SchemaData = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
group_id: { type: [ 'number' , 'string' ] },
|
group_id: { type: [ 'number' , 'string' ] },
|
||||||
enable: { type: 'boolean' }
|
enable: { type: ['boolean','string'] }
|
||||||
},
|
},
|
||||||
required: ['group_id', 'enable']
|
required: ['group_id']
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
@@ -18,7 +18,7 @@ export default class SetGroupWholeBan extends BaseAction<Payload, null> {
|
|||||||
actionName = ActionName.SetGroupWholeBan;
|
actionName = ActionName.SetGroupWholeBan;
|
||||||
PayloadSchema = SchemaData;
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
const enable = payload.enable.toString() === 'true';
|
const enable = payload.enable?.toString() !== 'false';
|
||||||
await NTQQGroupApi.banGroup(payload.group_id.toString(), enable);
|
await NTQQGroupApi.banGroup(payload.group_id.toString(), enable);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,7 @@ const SchemaData = {
|
|||||||
approve: { type: ['string', 'boolean'] },
|
approve: { type: ['string', 'boolean'] },
|
||||||
remark: { type: 'string' }
|
remark: { type: 'string' }
|
||||||
},
|
},
|
||||||
required: ['flag', 'approve']
|
required: ['flag']
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
@@ -20,7 +20,7 @@ export default class SetFriendAddRequest extends BaseAction<Payload, null> {
|
|||||||
actionName = ActionName.SetFriendAddRequest;
|
actionName = ActionName.SetFriendAddRequest;
|
||||||
PayloadSchema = SchemaData;
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
const approve = payload.approve.toString() === 'true';
|
const approve = payload.approve?.toString() !== 'false';
|
||||||
const request = friendRequests[payload.flag];
|
const request = friendRequests[payload.flag];
|
||||||
await NTQQFriendApi.handleFriendRequest(request, approve);
|
await NTQQFriendApi.handleFriendRequest(request, approve);
|
||||||
return null;
|
return null;
|
||||||
|
Reference in New Issue
Block a user