mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
refactor: action param handle
This commit is contained in:
parent
17cbe74fa3
commit
f180687ba3
@ -15,7 +15,7 @@ const SchemaData = {
|
|||||||
user_id: { type: ['number', 'string'] },
|
user_id: { type: ['number', 'string'] },
|
||||||
message_seq: { type: 'number' },
|
message_seq: { type: 'number' },
|
||||||
count: { type: ['number', 'string'] },
|
count: { type: ['number', 'string'] },
|
||||||
reverseOrder: { type: 'boolean' },
|
reverseOrder: { type: ['boolean', 'string'] },
|
||||||
},
|
},
|
||||||
required: ['user_id'],
|
required: ['user_id'],
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
@ -33,7 +33,7 @@ export default class GetFriendMsgHistory extends BaseAction<Payload, Response> {
|
|||||||
//处理参数
|
//处理参数
|
||||||
const uid = await NTQQUserApi.getUidByUinV2(payload.user_id.toString());
|
const uid = await NTQQUserApi.getUidByUinV2(payload.user_id.toString());
|
||||||
const MsgCount = +(payload.count ?? 20);
|
const MsgCount = +(payload.count ?? 20);
|
||||||
const isReverseOrder = payload.reverseOrder || true;
|
const isReverseOrder = typeof payload.reverseOrder === 'string' ? payload.reverseOrder === 'true' : !!payload.reverseOrder;
|
||||||
if (!uid) throw `记录${payload.user_id}不存在`;
|
if (!uid) throw `记录${payload.user_id}不存在`;
|
||||||
const friend = await NTQQFriendApi.isBuddy(uid);
|
const friend = await NTQQFriendApi.isBuddy(uid);
|
||||||
const peer = { chatType: friend ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid: uid };
|
const peer = { chatType: friend ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid: uid };
|
||||||
|
@ -15,7 +15,7 @@ const SchemaData = {
|
|||||||
group_id: { type: ['number', 'string'] },
|
group_id: { type: ['number', 'string'] },
|
||||||
message_seq: { type: 'number' },
|
message_seq: { type: 'number' },
|
||||||
count: { type: ['number', 'string'] },
|
count: { type: ['number', 'string'] },
|
||||||
reverseOrder: { type: 'boolean' },
|
reverseOrder: { type: ['boolean', 'string'] },
|
||||||
},
|
},
|
||||||
required: ['group_id'],
|
required: ['group_id'],
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
@ -29,7 +29,7 @@ export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Resp
|
|||||||
async _handle(payload: Payload): Promise<Response> {
|
async _handle(payload: Payload): Promise<Response> {
|
||||||
const NTQQMsgApi = this.core.apis.MsgApi;
|
const NTQQMsgApi = this.core.apis.MsgApi;
|
||||||
//处理参数
|
//处理参数
|
||||||
const isReverseOrder = payload.reverseOrder || true;
|
const isReverseOrder = typeof payload.reverseOrder === 'string' ? payload.reverseOrder === 'true' : !!payload.reverseOrder;
|
||||||
const MsgCount = +(payload.count ?? 20);
|
const MsgCount = +(payload.count ?? 20);
|
||||||
const peer: Peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: payload.group_id.toString() };
|
const peer: Peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: payload.group_id.toString() };
|
||||||
//拉取消息
|
//拉取消息
|
||||||
|
@ -10,8 +10,8 @@ const SchemaData = {
|
|||||||
group_id: { type: ['number', 'string'] },
|
group_id: { type: ['number', 'string'] },
|
||||||
content: { type: 'string' },
|
content: { type: 'string' },
|
||||||
image: { type: 'string' },
|
image: { type: 'string' },
|
||||||
pinned: { type: 'number' },
|
pinned: { type: ['number', 'string'] },
|
||||||
confirmRequired: { type: 'number' },
|
confirmRequired: { type: ['number', 'string'] },
|
||||||
},
|
},
|
||||||
required: ['group_id', 'content'],
|
required: ['group_id', 'content'],
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
@ -49,14 +49,8 @@ export class SendGroupNotice extends BaseAction<Payload, null> {
|
|||||||
}
|
}
|
||||||
UploadImage = ImageUploadResult.picInfo;
|
UploadImage = ImageUploadResult.picInfo;
|
||||||
}
|
}
|
||||||
let Notice_Pinned = 0;
|
let Notice_Pinned = +(payload.pinned ?? 0);
|
||||||
let Notice_confirmRequired = 0;
|
let Notice_confirmRequired = +(payload.confirmRequired ?? 0);
|
||||||
if (!payload.pinned) {
|
|
||||||
Notice_Pinned = 0;
|
|
||||||
}
|
|
||||||
if (!payload.confirmRequired) {
|
|
||||||
Notice_confirmRequired = 0;
|
|
||||||
}
|
|
||||||
const PublishGroupBulletinResult = await NTQQGroupApi.publishGroupBulletin(payload.group_id.toString(), payload.content, UploadImage, Notice_Pinned, Notice_confirmRequired);
|
const PublishGroupBulletinResult = await NTQQGroupApi.publishGroupBulletin(payload.group_id.toString(), payload.content, UploadImage, Notice_Pinned, Notice_confirmRequired);
|
||||||
|
|
||||||
if (PublishGroupBulletinResult.result != 0) {
|
if (PublishGroupBulletinResult.result != 0) {
|
||||||
|
@ -3,8 +3,6 @@ import { ActionName, BaseCheckResult } from '../types';
|
|||||||
import * as fs from 'node:fs';
|
import * as fs from 'node:fs';
|
||||||
import { checkFileReceived, uri2local } from '@/common/utils/file';
|
import { checkFileReceived, uri2local } from '@/common/utils/file';
|
||||||
|
|
||||||
// import { log } from "../../../common/utils";
|
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
file: string,
|
file: string,
|
||||||
group_id: number
|
group_id: number
|
||||||
@ -42,7 +40,6 @@ export default class SetGroupPortrait extends BaseAction<Payload, any> {
|
|||||||
if (!ret) {
|
if (!ret) {
|
||||||
throw `头像${payload.file}设置失败,api无返回`;
|
throw `头像${payload.file}设置失败,api无返回`;
|
||||||
}
|
}
|
||||||
// log(`头像设置返回:${JSON.stringify(ret)}`)
|
|
||||||
if (ret['result'] == 1004022) {
|
if (ret['result'] == 1004022) {
|
||||||
throw `头像${payload.file}设置失败,文件可能不是图片格式或权限不足`;
|
throw `头像${payload.file}设置失败,文件可能不是图片格式或权限不足`;
|
||||||
} else if (ret['result'] != 0) {
|
} else if (ret['result'] != 0) {
|
||||||
|
@ -7,7 +7,7 @@ const SchemaData = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
group_id: { type: ['number', 'string'] },
|
group_id: { type: ['number', 'string'] },
|
||||||
pages: { type: 'number' },
|
pages: { type: ['number', 'string'] },
|
||||||
},
|
},
|
||||||
required: ['group_id'],
|
required: ['group_id'],
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
@ -20,7 +20,7 @@ export class GetGroupEssence extends BaseAction<Payload, GroupEssenceMsgRet> {
|
|||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const NTQQWebApi = this.core.apis.WebApi;
|
const NTQQWebApi = this.core.apis.WebApi;
|
||||||
const ret = await NTQQWebApi.getGroupEssenceMsg(payload.group_id.toString(), (payload.pages || "0").toString());
|
const ret = await NTQQWebApi.getGroupEssenceMsg(payload.group_id.toString(), (+(payload.pages ?? 0)).toString());
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
throw new Error('获取失败');
|
throw new Error('获取失败');
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,6 @@ export class GetGroupNotice extends BaseAction<Payload, GroupNotice[]> {
|
|||||||
for (const key in ret.feeds) {
|
for (const key in ret.feeds) {
|
||||||
const retApiNotice: WebApiGroupNoticeFeed = ret.feeds[key];
|
const retApiNotice: WebApiGroupNoticeFeed = ret.feeds[key];
|
||||||
const retNotice: GroupNotice = {
|
const retNotice: GroupNotice = {
|
||||||
//...ret.feeds[key],
|
|
||||||
notice_id: retApiNotice.fid,
|
notice_id: retApiNotice.fid,
|
||||||
sender_id: retApiNotice.u,
|
sender_id: retApiNotice.u,
|
||||||
publish_time: retApiNotice.pubt,
|
publish_time: retApiNotice.pubt,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user