mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
fix: 修正部分接口的参数、返回值,提高兼容性 (#1072)
* fix: 修正`get_group_system_msg` `get_group_honor_info`接口返回值 提升兼容性 * fix: `create_group_file_folder` 接口兼容性提升
This commit is contained in:
@@ -604,7 +604,7 @@ const oneBotHttpApiGroup = {
|
|||||||
response: baseResponseSchema.extend({
|
response: baseResponseSchema.extend({
|
||||||
data: z
|
data: z
|
||||||
.object({
|
.object({
|
||||||
group_id: z.string().describe('群号'),
|
group_id: z.number().describe('群号'),
|
||||||
current_talkative: z
|
current_talkative: z
|
||||||
.object({
|
.object({
|
||||||
user_id: z.number().describe('QQ 号'),
|
user_id: z.number().describe('QQ 号'),
|
||||||
|
@@ -264,7 +264,7 @@ export class NTQQWebApi {
|
|||||||
async getGroupHonorInfo(groupCode: string, getType: WebHonorType) {
|
async getGroupHonorInfo(groupCode: string, getType: WebHonorType) {
|
||||||
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
||||||
let HonorInfo = {
|
let HonorInfo = {
|
||||||
group_id: groupCode,
|
group_id: Number(groupCode),
|
||||||
current_talkative: {},
|
current_talkative: {},
|
||||||
talkative_list: [],
|
talkative_list: [],
|
||||||
performer_list: [],
|
performer_list: [],
|
||||||
|
@@ -4,7 +4,10 @@ import { Static, Type } from '@sinclair/typebox';
|
|||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
folder_name: Type.String(),
|
// 兼容gocq 与name二选一
|
||||||
|
folder_name: Type.Optional(Type.String()),
|
||||||
|
// 兼容gocq 与folder_name二选一
|
||||||
|
name: Type.Optional(Type.String()),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
@@ -16,6 +19,7 @@ export class CreateGroupFileFolder extends OneBotAction<Payload, ResponseType>
|
|||||||
override actionName = ActionName.GoCQHTTP_CreateGroupFileFolder;
|
override actionName = ActionName.GoCQHTTP_CreateGroupFileFolder;
|
||||||
override payloadSchema = SchemaData;
|
override payloadSchema = SchemaData;
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
return (await this.core.apis.GroupApi.creatGroupFileFolder(payload.group_id.toString(), payload.folder_name)).resultWithGroupItem;
|
const folderName = payload.folder_name || payload.name;
|
||||||
|
return (await this.core.apis.GroupApi.creatGroupFileFolder(payload.group_id.toString(), folderName!)).resultWithGroupItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,10 +8,16 @@ interface GroupNotice {
|
|||||||
notice_id: string;
|
notice_id: string;
|
||||||
message: {
|
message: {
|
||||||
text: string
|
text: string
|
||||||
|
// 保持一段时间兼容性 防止以往版本出现问题 后续版本可考虑移除
|
||||||
image: Array<{
|
image: Array<{
|
||||||
height: string
|
height: string
|
||||||
width: string
|
width: string
|
||||||
id: string
|
id: string
|
||||||
|
}>,
|
||||||
|
images: Array<{
|
||||||
|
height: string
|
||||||
|
width: string
|
||||||
|
id: string
|
||||||
}>
|
}>
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -40,15 +46,18 @@ export class GetGroupNotice extends OneBotAction<Payload, GroupNotice[]> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const retApiNotice: WebApiGroupNoticeFeed = ret.feeds[key];
|
const retApiNotice: WebApiGroupNoticeFeed = ret.feeds[key];
|
||||||
|
const image = retApiNotice.msg.pics?.map((pic) => {
|
||||||
|
return { id: pic.id, height: pic.h, width: pic.w };
|
||||||
|
}) || [];
|
||||||
|
|
||||||
const retNotice: GroupNotice = {
|
const retNotice: GroupNotice = {
|
||||||
notice_id: retApiNotice.fid,
|
notice_id: retApiNotice.fid,
|
||||||
sender_id: retApiNotice.u,
|
sender_id: retApiNotice.u,
|
||||||
publish_time: retApiNotice.pubt,
|
publish_time: retApiNotice.pubt,
|
||||||
message: {
|
message: {
|
||||||
text: retApiNotice.msg.text,
|
text: retApiNotice.msg.text,
|
||||||
image: retApiNotice.msg.pics?.map((pic) => {
|
image,
|
||||||
return { id: pic.id, height: pic.h, width: pic.w };
|
images: image,
|
||||||
}) || [],
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
retNotices.push(retNotice);
|
retNotices.push(retNotice);
|
||||||
|
@@ -4,6 +4,7 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Notify } from '@/onebot/types';
|
import { Notify } from '@/onebot/types';
|
||||||
|
|
||||||
interface RetData {
|
interface RetData {
|
||||||
|
invited_requests: Notify[];
|
||||||
InvitedRequest: Notify[];
|
InvitedRequest: Notify[];
|
||||||
join_requests: Notify[];
|
join_requests: Notify[];
|
||||||
}
|
}
|
||||||
@@ -13,7 +14,7 @@ export class GetGroupSystemMsg extends OneBotAction<void, RetData> {
|
|||||||
|
|
||||||
async _handle(): Promise<RetData> {
|
async _handle(): Promise<RetData> {
|
||||||
const SingleScreenNotifies = await this.core.apis.GroupApi.getSingleScreenNotifies(false, 50);
|
const SingleScreenNotifies = await this.core.apis.GroupApi.getSingleScreenNotifies(false, 50);
|
||||||
const retData: RetData = { InvitedRequest: [], join_requests: [] };
|
const retData: RetData = { invited_requests: [], InvitedRequest: [], join_requests: [] };
|
||||||
|
|
||||||
const notifyPromises = SingleScreenNotifies.map(async (SSNotify) => {
|
const notifyPromises = SingleScreenNotifies.map(async (SSNotify) => {
|
||||||
const invitorUin = SSNotify.user1?.uid ? +await this.core.apis.UserApi.getUinByUidV2(SSNotify.user1.uid) : 0;
|
const invitorUin = SSNotify.user1?.uid ? +await this.core.apis.UserApi.getUinByUidV2(SSNotify.user1.uid) : 0;
|
||||||
@@ -39,6 +40,7 @@ export class GetGroupSystemMsg extends OneBotAction<void, RetData> {
|
|||||||
|
|
||||||
await Promise.all(notifyPromises);
|
await Promise.all(notifyPromises);
|
||||||
|
|
||||||
|
retData.invited_requests = retData.InvitedRequest;
|
||||||
return retData;
|
return retData;
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user