mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 21:10:23 +00:00
refactor: 项目结构
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import { OB11Construct } from '@/onebot/helper/data';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
|
||||
@@ -8,7 +8,7 @@ export class GetFriendWithCategory extends OneBotAction<void, any> {
|
||||
async _handle(payload: void) {
|
||||
return (await this.core.apis.FriendApi.getBuddyV2ExWithCate()).map(category => ({
|
||||
...category,
|
||||
buddyList: OB11Entities.friendsV2(category.buddyList),
|
||||
buddyList: OB11Construct.friends(category.buddyList),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import { OB11Construct } from '@/onebot/helper/data';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
@@ -31,7 +31,7 @@ export class GetGroupFilesByFolder extends OneBotAction<any, any> {
|
||||
}).catch(() => []);
|
||||
return {
|
||||
files: ret.filter(item => item.fileInfo)
|
||||
.map(item => OB11Entities.file(item.peerId, item.fileInfo!)),
|
||||
.map(item => OB11Construct.file(item.peerId, item.fileInfo!)),
|
||||
folders: [] as [],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { OB11GroupFile, OB11GroupFileFolder } from '@/onebot';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import { OB11Construct } from '@/onebot/helper/data';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
@@ -32,9 +32,9 @@ export class GetGroupRootFiles extends OneBotAction<Payload, {
|
||||
|
||||
return {
|
||||
files: ret.filter(item => item.fileInfo)
|
||||
.map(item => OB11Entities.file(item.peerId, item.fileInfo!)),
|
||||
.map(item => OB11Construct.file(item.peerId, item.fileInfo!)),
|
||||
folders: ret.filter(item => item.folderInfo)
|
||||
.map(item => OB11Entities.folder(item.peerId, item.folderInfo!)),
|
||||
.map(item => OB11Construct.folder(item.peerId, item.folderInfo!)),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { OB11User, OB11UserSex } from '@/onebot';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import { OB11Construct } from '@/onebot/helper/data';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { calcQQLevel } from '@/common/helper';
|
||||
@@ -36,7 +36,7 @@ export default class GoCQHTTPGetStrangerInfo extends OneBotAction<Payload, OB11U
|
||||
age: extendData.detail.simpleInfo.baseInfo.age ?? info.age,
|
||||
qid: extendData.detail.simpleInfo.baseInfo.qid,
|
||||
qqLevel: calcQQLevel(extendData.detail.commonExt?.qqLevel ?? info.qqLevel),
|
||||
sex: OB11Entities.sex(extendData.detail.simpleInfo.baseInfo.sex) ?? OB11UserSex.unknown,
|
||||
sex: OB11Construct.sex(extendData.detail.simpleInfo.baseInfo.sex) ?? OB11UserSex.unknown,
|
||||
long_nick: extendData.detail.simpleInfo.baseInfo.longNick ?? info.longNick,
|
||||
reg_time: extendData.detail.commonExt?.regTime ?? info.regTime,
|
||||
is_vip: extendData.detail.simpleInfo.vasInfo?.svipFlag,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { OB11Group } from '@/onebot';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import { OB11Construct } from '@/onebot/helper/data';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
@@ -31,7 +31,7 @@ class GetGroupInfo extends OneBotAction<Payload, OB11Group> {
|
||||
max_member_count: data.searchGroupInfo.maxMemberNum,
|
||||
};
|
||||
}
|
||||
return OB11Entities.group(group);
|
||||
return OB11Construct.group(group);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { OB11Group } from '@/onebot';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import { OB11Construct } from '@/onebot/helper/data';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
@@ -18,7 +18,7 @@ class GetGroupList extends OneBotAction<Payload, OB11Group[]> {
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
return OB11Entities.groups(
|
||||
return OB11Construct.groups(
|
||||
await this.core.apis.GroupApi.getGroups(
|
||||
typeof payload.no_cache === 'string' ? payload.no_cache === 'true' : !!payload.no_cache));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { OB11GroupMember } from '@/onebot';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import { OB11Construct } from '@/onebot/helper/data';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
@@ -43,7 +43,7 @@ class GetGroupMemberInfo extends OneBotAction<Payload, OB11GroupMember> {
|
||||
} else {
|
||||
this.core.context.logger.logDebug(`获取群成员详细信息失败, 只能返回基础信息`);
|
||||
}
|
||||
return OB11Entities.groupMember(payload.group_id.toString(), member);
|
||||
return OB11Construct.groupMember(payload.group_id.toString(), member);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { OB11GroupMember } from '@/onebot';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import { OB11Construct } from '@/onebot/helper/data';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
@@ -30,7 +30,7 @@ export class GetGroupMemberList extends OneBotAction<Payload, OB11GroupMember[]>
|
||||
groupMembers = memberCache.get(groupIdStr) ?? await this.core.apis.GroupApi.getGroupMembersV2(groupIdStr);
|
||||
}
|
||||
const memberPromises = Array.from(groupMembers.values()).map(item =>
|
||||
OB11Entities.groupMember(groupIdStr, item)
|
||||
OB11Construct.groupMember(groupIdStr, item)
|
||||
);
|
||||
const _groupMembers = await Promise.all(memberPromises);
|
||||
const MemberMap = new Map(_groupMembers.map(member => [member.user_id, member]));
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
OB11PostSendMsg,
|
||||
} from '@/onebot/types';
|
||||
import { ActionName, BaseCheckResult } from '@/onebot/action/router';
|
||||
import { decodeCQCode } from '@/onebot/cqcode';
|
||||
import { decodeCQCode } from '@/onebot/helper/cqcode';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
import { ChatType, ElementType, NapCatCore, Peer, RawMessage, SendArkElement, SendMessageElement } from '@/core';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { OB11User } from '@/onebot';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import { OB11Construct } from '@/onebot/helper/data';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
|
||||
@@ -7,7 +7,7 @@ class GetLoginInfo extends OneBotAction<null, OB11User> {
|
||||
actionName = ActionName.GetLoginInfo;
|
||||
|
||||
async _handle(payload: null) {
|
||||
return OB11Entities.selfInfo(this.core.selfInfo);
|
||||
return OB11Construct.selfInfo(this.core.selfInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { OB11User } from '@/onebot';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import { OB11Construct } from '@/onebot/helper/data';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
@@ -19,6 +19,6 @@ export default class GetFriendList extends OneBotAction<Payload, OB11User[]> {
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
//全新逻辑
|
||||
return OB11Entities.friendsV2(await this.core.apis.FriendApi.getBuddyV2(typeof payload.no_cache === 'string' ? payload.no_cache === 'true' : !!payload.no_cache));
|
||||
return OB11Construct.friends(await this.core.apis.FriendApi.getBuddy(typeof payload.no_cache === 'string' ? payload.no_cache === 'true' : !!payload.no_cache));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user