mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
feat: check action data 2
This commit is contained in:
parent
d4e5201913
commit
62eee5f05c
@ -7,21 +7,27 @@ import { dbUtil } from '@/core/utils/db';
|
|||||||
import { NTQQMsgApi } from '@/core/apis/msg';
|
import { NTQQMsgApi } from '@/core/apis/msg';
|
||||||
import { OB11Constructor } from '../../constructor';
|
import { OB11Constructor } from '../../constructor';
|
||||||
import { logDebug } from '@/common/utils/log';
|
import { logDebug } from '@/common/utils/log';
|
||||||
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
|
||||||
interface Payload {
|
|
||||||
user_id: number
|
|
||||||
message_seq: number,
|
|
||||||
count: number
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Response {
|
interface Response {
|
||||||
messages: OB11Message[];
|
messages: OB11Message[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SchemaData = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
user_id: { type: 'number' },
|
||||||
|
message_seq: { type: 'number' },
|
||||||
|
count: { type: 'number' }
|
||||||
|
},
|
||||||
|
required: ['user_id', 'message_seq', 'count']
|
||||||
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
export default class GetFriendMsgHistory extends BaseAction<Payload, Response> {
|
export default class GetFriendMsgHistory extends BaseAction<Payload, Response> {
|
||||||
actionName = ActionName.GetFriendMsgHistory;
|
actionName = ActionName.GetFriendMsgHistory;
|
||||||
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload): Promise<Response> {
|
protected async _handle(payload: Payload): Promise<Response> {
|
||||||
const uid = getUidByUin(payload.user_id.toString());
|
const uid = getUidByUin(payload.user_id.toString());
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
|
@ -1,21 +1,23 @@
|
|||||||
import { OB11User } from '../../types';
|
|
||||||
import { OB11Constructor } from '../../constructor';
|
|
||||||
import { friends } from '@/core/data';
|
|
||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { NTQQUserApi, WebApi, WebHonorType } from '@/core/apis';
|
import { WebApi, WebHonorType } from '@/core/apis';
|
||||||
interface Payload {
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
group_id: number,
|
const SchemaData = {
|
||||||
type?: WebHonorType
|
type: 'object',
|
||||||
}
|
properties: {
|
||||||
|
group_id: { type: 'number' },
|
||||||
|
type: { enum: [WebHonorType.ALL, WebHonorType.EMOTION, WebHonorType.LEGEND, WebHonorType.PERFROMER, WebHonorType.STORONGE_NEWBI, WebHonorType.TALKACTIVE] }
|
||||||
|
},
|
||||||
|
required: ['group_id']
|
||||||
|
} as const satisfies JSONSchema;
|
||||||
|
// enum是不是有点抽象
|
||||||
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
export class GetGroupHonorInfo extends BaseAction<Payload, Array<any>> {
|
export class GetGroupHonorInfo extends BaseAction<Payload, Array<any>> {
|
||||||
actionName = ActionName.GetGroupHonorInfo;
|
actionName = ActionName.GetGroupHonorInfo;
|
||||||
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle(payload: Payload) {
|
||||||
// console.log(await NTQQUserApi.getRobotUinRange());
|
|
||||||
if (!payload.group_id) {
|
|
||||||
throw '缺少参数group_id';
|
|
||||||
}
|
|
||||||
if (!payload.type) {
|
if (!payload.type) {
|
||||||
payload.type = WebHonorType.ALL;
|
payload.type = WebHonorType.ALL;
|
||||||
}
|
}
|
||||||
|
@ -7,21 +7,26 @@ import { dbUtil } from '@/core/utils/db';
|
|||||||
import { NTQQMsgApi } from '@/core/apis/msg';
|
import { NTQQMsgApi } from '@/core/apis/msg';
|
||||||
import { OB11Constructor } from '../../constructor';
|
import { OB11Constructor } from '../../constructor';
|
||||||
import { logDebug } from '@/common/utils/log';
|
import { logDebug } from '@/common/utils/log';
|
||||||
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
|
||||||
interface Payload {
|
|
||||||
group_id: number
|
|
||||||
message_seq: number,
|
|
||||||
count: number
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Response {
|
interface Response {
|
||||||
messages: OB11Message[];
|
messages: OB11Message[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SchemaData = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
group_id: { type: 'number' },
|
||||||
|
message_seq: { type: 'number' },
|
||||||
|
count: { type: 'number' }
|
||||||
|
},
|
||||||
|
required: ['group_id', 'message_seq', 'count']
|
||||||
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Response> {
|
export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Response> {
|
||||||
actionName = ActionName.GoCQHTTP_GetGroupMsgHistory;
|
actionName = ActionName.GoCQHTTP_GetGroupMsgHistory;
|
||||||
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload): Promise<Response> {
|
protected async _handle(payload: Payload): Promise<Response> {
|
||||||
const group = await getGroup(payload.group_id.toString());
|
const group = await getGroup(payload.group_id.toString());
|
||||||
if (!group) {
|
if (!group) {
|
||||||
|
@ -5,12 +5,22 @@ import { OB11Constructor } from '../../constructor';
|
|||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { NTQQUserApi } from '@/core/apis/user';
|
import { NTQQUserApi } from '@/core/apis/user';
|
||||||
import { log, logDebug } from '@/common/utils/log';
|
import { log, logDebug } from '@/common/utils/log';
|
||||||
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
|
||||||
|
const SchemaData = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
user_id: { type: 'number' },
|
||||||
|
},
|
||||||
|
required: ['user_id']
|
||||||
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
export default class GoCQHTTPGetStrangerInfo extends BaseAction<{ user_id: number }, OB11User> {
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
|
export default class GoCQHTTPGetStrangerInfo extends BaseAction<Payload, OB11User> {
|
||||||
actionName = ActionName.GoCQHTTP_GetStrangerInfo;
|
actionName = ActionName.GoCQHTTP_GetStrangerInfo;
|
||||||
|
|
||||||
protected async _handle(payload: { user_id: number }): Promise<OB11User> {
|
protected async _handle(payload: Payload): Promise<OB11User> {
|
||||||
const user_id = payload.user_id.toString();
|
const user_id = payload.user_id.toString();
|
||||||
logDebug('uidMaps', uid2UinMap);
|
logDebug('uidMaps', uid2UinMap);
|
||||||
const uid = getUidByUin(user_id);
|
const uid = getUidByUin(user_id);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import SendMsg, { normalize } from '../msg/SendMsg';
|
import SendMsg, { normalize } from '../msg/SendMsg';
|
||||||
import { OB11PostSendMsg } from '../../types';
|
import { OB11PostSendMsg } from '../../types';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
|
// 未验证
|
||||||
export class GoCQHTTPSendForwardMsg extends SendMsg {
|
export class GoCQHTTPSendForwardMsg extends SendMsg {
|
||||||
actionName = ActionName.GoCQHTTP_SendForwardMsg;
|
actionName = ActionName.GoCQHTTP_SendForwardMsg;
|
||||||
|
|
||||||
|
@ -3,14 +3,21 @@ import BaseAction from '../BaseAction';
|
|||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { NTQQGroupApi, WebApi } from '@/core/apis';
|
import { NTQQGroupApi, WebApi } from '@/core/apis';
|
||||||
import { unlink } from 'node:fs';
|
import { unlink } from 'node:fs';
|
||||||
interface Payload {
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
group_id: string;
|
const SchemaData = {
|
||||||
content: string;
|
type: 'object',
|
||||||
image?: string;
|
properties: {
|
||||||
pinned?: number;
|
group_id: { type: 'number' },
|
||||||
confirmRequired?: number;
|
content: { type: 'string' },
|
||||||
|
image: { type: 'string' },
|
||||||
|
pinned: { type: 'number' },
|
||||||
|
confirmRequired: { type: 'number' }
|
||||||
|
},
|
||||||
|
required: ['group_id', 'content']
|
||||||
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
}
|
|
||||||
export class SendGroupNotice extends BaseAction<Payload, null> {
|
export class SendGroupNotice extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.GoCQHTTP_SendGroupNotice;
|
actionName = ActionName.GoCQHTTP_SendGroupNotice;
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle(payload: Payload) {
|
||||||
@ -29,7 +36,7 @@ export class SendGroupNotice extends BaseAction<Payload, null> {
|
|||||||
throw `群公告${payload.image}设置失败,获取资源失败`;
|
throw `群公告${payload.image}设置失败,获取资源失败`;
|
||||||
}
|
}
|
||||||
await checkFileReceived(Image_path, 5000); // 文件不存在QQ会崩溃,需要提前判断
|
await checkFileReceived(Image_path, 5000); // 文件不存在QQ会崩溃,需要提前判断
|
||||||
let ImageUploadResult = await NTQQGroupApi.uploadGroupBulletinPic(payload.group_id, Image_path);
|
let ImageUploadResult = await NTQQGroupApi.uploadGroupBulletinPic(payload.group_id.toString(), Image_path);
|
||||||
if (ImageUploadResult.errCode != 0) {
|
if (ImageUploadResult.errCode != 0) {
|
||||||
throw `群公告${payload.image}设置失败,图片上传失败`;
|
throw `群公告${payload.image}设置失败,图片上传失败`;
|
||||||
}
|
}
|
||||||
@ -46,7 +53,7 @@ export class SendGroupNotice extends BaseAction<Payload, null> {
|
|||||||
if (!payload.confirmRequired) {
|
if (!payload.confirmRequired) {
|
||||||
Notice_confirmRequired = 0;
|
Notice_confirmRequired = 0;
|
||||||
}
|
}
|
||||||
let PublishGroupBulletinResult = await NTQQGroupApi.publishGroupBulletin(payload.group_id, payload.content, UploadImage, Notice_Pinned, Notice_confirmRequired);
|
let PublishGroupBulletinResult = await NTQQGroupApi.publishGroupBulletin(payload.group_id.toString(), payload.content, UploadImage, Notice_Pinned, Notice_confirmRequired);
|
||||||
|
|
||||||
if (PublishGroupBulletinResult.result! = 0) {
|
if (PublishGroupBulletinResult.result! = 0) {
|
||||||
throw `设置群公告失败,错误信息:${PublishGroupBulletinResult.errMsg}`;
|
throw `设置群公告失败,错误信息:${PublishGroupBulletinResult.errMsg}`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user