mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
refactor: 项目结构
This commit is contained in:
parent
a5d4998933
commit
a19358da5b
@ -24,7 +24,7 @@ export class NTQQFriendApi {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBuddyV2(refresh = false): Promise<FriendV2[]> {
|
async getBuddy(refresh = false): Promise<FriendV2[]> {
|
||||||
return Array.from((await this.getBuddyV2SimpleInfoMap(refresh)).values());
|
return Array.from((await this.getBuddyV2SimpleInfoMap(refresh)).values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ export class NTQQFriendApi {
|
|||||||
categoryName: category.categroyName,
|
categoryName: category.categroyName,
|
||||||
categoryMbCount: category.categroyMbCount,
|
categoryMbCount: category.categroyMbCount,
|
||||||
onlineCount: category.onlineCount,
|
onlineCount: category.onlineCount,
|
||||||
buddyList: category.buddyUids.map(uid => data.get(uid)!).filter(value => value),
|
buddyList: category.buddyUids.map(uid => data.get(uid)).filter(value => !!value),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { OB11Entities } from '@/onebot/entities';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ export class GetFriendWithCategory extends OneBotAction<void, any> {
|
|||||||
async _handle(payload: void) {
|
async _handle(payload: void) {
|
||||||
return (await this.core.apis.FriendApi.getBuddyV2ExWithCate()).map(category => ({
|
return (await this.core.apis.FriendApi.getBuddyV2ExWithCate()).map(category => ({
|
||||||
...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 { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { OB11Entities } from '@/onebot/entities';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@ -31,7 +31,7 @@ export class GetGroupFilesByFolder extends OneBotAction<any, any> {
|
|||||||
}).catch(() => []);
|
}).catch(() => []);
|
||||||
return {
|
return {
|
||||||
files: ret.filter(item => item.fileInfo)
|
files: ret.filter(item => item.fileInfo)
|
||||||
.map(item => OB11Entities.file(item.peerId, item.fileInfo!)),
|
.map(item => OB11Construct.file(item.peerId, item.fileInfo!)),
|
||||||
folders: [] as [],
|
folders: [] as [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { OB11GroupFile, OB11GroupFileFolder } from '@/onebot';
|
import { OB11GroupFile, OB11GroupFileFolder } from '@/onebot';
|
||||||
import { OB11Entities } from '@/onebot/entities';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@ -32,9 +32,9 @@ export class GetGroupRootFiles extends OneBotAction<Payload, {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
files: ret.filter(item => item.fileInfo)
|
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)
|
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 { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { OB11User, OB11UserSex } from '@/onebot';
|
import { OB11User, OB11UserSex } from '@/onebot';
|
||||||
import { OB11Entities } from '@/onebot/entities';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import { calcQQLevel } from '@/common/helper';
|
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,
|
age: extendData.detail.simpleInfo.baseInfo.age ?? info.age,
|
||||||
qid: extendData.detail.simpleInfo.baseInfo.qid,
|
qid: extendData.detail.simpleInfo.baseInfo.qid,
|
||||||
qqLevel: calcQQLevel(extendData.detail.commonExt?.qqLevel ?? info.qqLevel),
|
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,
|
long_nick: extendData.detail.simpleInfo.baseInfo.longNick ?? info.longNick,
|
||||||
reg_time: extendData.detail.commonExt?.regTime ?? info.regTime,
|
reg_time: extendData.detail.commonExt?.regTime ?? info.regTime,
|
||||||
is_vip: extendData.detail.simpleInfo.vasInfo?.svipFlag,
|
is_vip: extendData.detail.simpleInfo.vasInfo?.svipFlag,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { OB11Group } from '@/onebot';
|
import { OB11Group } from '@/onebot';
|
||||||
import { OB11Entities } from '@/onebot/entities';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
@ -31,7 +31,7 @@ class GetGroupInfo extends OneBotAction<Payload, OB11Group> {
|
|||||||
max_member_count: data.searchGroupInfo.maxMemberNum,
|
max_member_count: data.searchGroupInfo.maxMemberNum,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return OB11Entities.group(group);
|
return OB11Construct.group(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { OB11Group } from '@/onebot';
|
import { OB11Group } from '@/onebot';
|
||||||
import { OB11Entities } from '@/onebot/entities';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
@ -18,7 +18,7 @@ class GetGroupList extends OneBotAction<Payload, OB11Group[]> {
|
|||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
return OB11Entities.groups(
|
return OB11Construct.groups(
|
||||||
await this.core.apis.GroupApi.getGroups(
|
await this.core.apis.GroupApi.getGroups(
|
||||||
typeof payload.no_cache === 'string' ? payload.no_cache === 'true' : !!payload.no_cache));
|
typeof payload.no_cache === 'string' ? payload.no_cache === 'true' : !!payload.no_cache));
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { OB11GroupMember } from '@/onebot';
|
import { OB11GroupMember } from '@/onebot';
|
||||||
import { OB11Entities } from '@/onebot/entities';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
@ -43,7 +43,7 @@ class GetGroupMemberInfo extends OneBotAction<Payload, OB11GroupMember> {
|
|||||||
} else {
|
} else {
|
||||||
this.core.context.logger.logDebug(`获取群成员详细信息失败, 只能返回基础信息`);
|
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 { OB11GroupMember } from '@/onebot';
|
||||||
import { OB11Entities } from '@/onebot/entities';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
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);
|
groupMembers = memberCache.get(groupIdStr) ?? await this.core.apis.GroupApi.getGroupMembersV2(groupIdStr);
|
||||||
}
|
}
|
||||||
const memberPromises = Array.from(groupMembers.values()).map(item =>
|
const memberPromises = Array.from(groupMembers.values()).map(item =>
|
||||||
OB11Entities.groupMember(groupIdStr, item)
|
OB11Construct.groupMember(groupIdStr, item)
|
||||||
);
|
);
|
||||||
const _groupMembers = await Promise.all(memberPromises);
|
const _groupMembers = await Promise.all(memberPromises);
|
||||||
const MemberMap = new Map(_groupMembers.map(member => [member.user_id, member]));
|
const MemberMap = new Map(_groupMembers.map(member => [member.user_id, member]));
|
||||||
|
@ -7,7 +7,7 @@ import {
|
|||||||
OB11PostSendMsg,
|
OB11PostSendMsg,
|
||||||
} from '@/onebot/types';
|
} from '@/onebot/types';
|
||||||
import { ActionName, BaseCheckResult } from '@/onebot/action/router';
|
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 { MessageUnique } from '@/common/message-unique';
|
||||||
import { ChatType, ElementType, NapCatCore, Peer, RawMessage, SendArkElement, SendMessageElement } from '@/core';
|
import { ChatType, ElementType, NapCatCore, Peer, RawMessage, SendArkElement, SendMessageElement } from '@/core';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { OB11User } from '@/onebot';
|
import { OB11User } from '@/onebot';
|
||||||
import { OB11Entities } from '@/onebot/entities';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
|
|
||||||
@ -7,7 +7,7 @@ class GetLoginInfo extends OneBotAction<null, OB11User> {
|
|||||||
actionName = ActionName.GetLoginInfo;
|
actionName = ActionName.GetLoginInfo;
|
||||||
|
|
||||||
async _handle(payload: null) {
|
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 { OB11User } from '@/onebot';
|
||||||
import { OB11Entities } from '@/onebot/entities';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
import { ActionName } from '@/onebot/action/router';
|
import { ActionName } from '@/onebot/action/router';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
@ -19,6 +19,6 @@ export default class GetFriendList extends OneBotAction<Payload, OB11User[]> {
|
|||||||
|
|
||||||
async _handle(payload: Payload) {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@ import {
|
|||||||
} from '@/core';
|
} from '@/core';
|
||||||
import faceConfig from '@/core/external/face_config.json';
|
import faceConfig from '@/core/external/face_config.json';
|
||||||
import { NapCatOneBot11Adapter, OB11Message, OB11MessageData, OB11MessageDataType, OB11MessageFileBase, } from '@/onebot';
|
import { NapCatOneBot11Adapter, OB11Message, OB11MessageData, OB11MessageDataType, OB11MessageFileBase, } from '@/onebot';
|
||||||
import { OB11Entities } from '@/onebot/entities';
|
import { OB11Construct } from '@/onebot/helper/data';
|
||||||
import { EventType } from '@/onebot/event/OneBotEvent';
|
import { EventType } from '@/onebot/event/OneBotEvent';
|
||||||
import { encodeCQCode } from '@/onebot/cqcode';
|
import { encodeCQCode } from '@/onebot/helper/cqcode';
|
||||||
import { uri2local } from '@/common/file';
|
import { uri2local } from '@/common/file';
|
||||||
import { RequestUtil } from '@/common/request';
|
import { RequestUtil } from '@/common/request';
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
@ -736,7 +736,7 @@ export class OneBotMsgApi {
|
|||||||
let member = await this.core.apis.GroupApi.getGroupMember(msg.peerUin, msg.senderUin);
|
let member = await this.core.apis.GroupApi.getGroupMember(msg.peerUin, msg.senderUin);
|
||||||
if (!member) member = await this.core.apis.GroupApi.getGroupMember(msg.peerUin, msg.senderUin);
|
if (!member) member = await this.core.apis.GroupApi.getGroupMember(msg.peerUin, msg.senderUin);
|
||||||
if (member) {
|
if (member) {
|
||||||
resMsg.sender.role = OB11Entities.groupMemberRole(member.role);
|
resMsg.sender.role = OB11Construct.groupMemberRole(member.role);
|
||||||
resMsg.sender.nickname = member.nick;
|
resMsg.sender.nickname = member.nick;
|
||||||
}
|
}
|
||||||
} else if (msg.chatType == ChatType.KCHATTYPEC2C) {
|
} else if (msg.chatType == ChatType.KCHATTYPEC2C) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { OB11MessageData } from './types';
|
import { OB11MessageData } from '@/onebot/types';
|
||||||
|
|
||||||
const pattern = /\[CQ:(\w+)((,\w+=[^,\]]*)*)]/;
|
const pattern = /\[CQ:(\w+)((,\w+=[^,\]]*)*)]/;
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
import { calcQQLevel, FileNapCatOneBotUUID } from '@/common/helper';
|
import { calcQQLevel, FileNapCatOneBotUUID } from '@/common/helper';
|
||||||
import { Friend, FriendV2, Group, GroupFileInfoUpdateParamType, GroupMember, SelfInfo, Sex, User } from '@/core';
|
import { FriendV2, Group, GroupFileInfoUpdateParamType, GroupMember, SelfInfo, Sex } from '@/core';
|
||||||
import {
|
import {
|
||||||
OB11Group,
|
OB11Group,
|
||||||
OB11GroupFile,
|
OB11GroupFile,
|
||||||
@ -8,17 +8,16 @@ import {
|
|||||||
OB11GroupMemberRole,
|
OB11GroupMemberRole,
|
||||||
OB11User,
|
OB11User,
|
||||||
OB11UserSex,
|
OB11UserSex,
|
||||||
} from './types';
|
} from '../types';
|
||||||
|
export class OB11Construct {
|
||||||
export class OB11Entities {
|
|
||||||
static selfInfo(selfInfo: SelfInfo): OB11User {
|
static selfInfo(selfInfo: SelfInfo): OB11User {
|
||||||
return {
|
return {
|
||||||
user_id: parseInt(selfInfo.uin),
|
user_id: +selfInfo.uin,
|
||||||
nickname: selfInfo.nick,
|
nickname: selfInfo.nick,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static friendsV2(friends: FriendV2[]): OB11User[] {
|
static friends(friends: FriendV2[]): OB11User[] {
|
||||||
return friends.map(rawFriend => ({
|
return friends.map(rawFriend => ({
|
||||||
...rawFriend.baseInfo,
|
...rawFriend.baseInfo,
|
||||||
...rawFriend.coreInfo,
|
...rawFriend.coreInfo,
|
||||||
@ -30,16 +29,6 @@ export class OB11Entities {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
static friends(friends: Friend[]): OB11User[] {
|
|
||||||
return friends.map(rawFriend => ({
|
|
||||||
user_id: parseInt(rawFriend.uin),
|
|
||||||
nickname: rawFriend.nick,
|
|
||||||
remark: rawFriend.remark,
|
|
||||||
sex: this.sex(rawFriend.sex!),
|
|
||||||
level: 0,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
static groupMemberRole(role: number): OB11GroupMemberRole | undefined {
|
static groupMemberRole(role: number): OB11GroupMemberRole | undefined {
|
||||||
return {
|
return {
|
||||||
4: OB11GroupMemberRole.owner,
|
4: OB11GroupMemberRole.owner,
|
||||||
@ -59,11 +48,11 @@ export class OB11Entities {
|
|||||||
|
|
||||||
static groupMember(group_id: string, member: GroupMember): OB11GroupMember {
|
static groupMember(group_id: string, member: GroupMember): OB11GroupMember {
|
||||||
return {
|
return {
|
||||||
group_id: parseInt(group_id),
|
group_id: +group_id,
|
||||||
user_id: parseInt(member.uin),
|
user_id: +member.uin,
|
||||||
nickname: member.nick,
|
nickname: member.nick,
|
||||||
card: member.cardName,
|
card: member.cardName,
|
||||||
sex: OB11Entities.sex(member.sex!),
|
sex: this.sex(member.sex),
|
||||||
age: member.age ?? 0,
|
age: member.age ?? 0,
|
||||||
area: '',
|
area: '',
|
||||||
level: member.memberRealLevel?.toString() ?? '0',
|
level: member.memberRealLevel?.toString() ?? '0',
|
||||||
@ -75,29 +64,14 @@ export class OB11Entities {
|
|||||||
card_changeable: true,
|
card_changeable: true,
|
||||||
is_robot: member.isRobot,
|
is_robot: member.isRobot,
|
||||||
shut_up_timestamp: member.shutUpTime,
|
shut_up_timestamp: member.shutUpTime,
|
||||||
role: OB11Entities.groupMemberRole(member.role),
|
role: this.groupMemberRole(member.role),
|
||||||
title: member.memberSpecialTitle ?? '',
|
title: member.memberSpecialTitle ?? '',
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static stranger(user: User): OB11User {
|
|
||||||
return {
|
|
||||||
...user,
|
|
||||||
user_id: parseInt(user.uin),
|
|
||||||
nickname: user.nick,
|
|
||||||
sex: OB11Entities.sex(user.sex!),
|
|
||||||
age: 0,
|
|
||||||
qid: user.qid,
|
|
||||||
login_days: 0,
|
|
||||||
level: user.qqLevel && calcQQLevel(user.qqLevel) || 0,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static group(group: Group): OB11Group {
|
static group(group: Group): OB11Group {
|
||||||
return {
|
return {
|
||||||
group_id: parseInt(group.groupCode),
|
group_id: +group.groupCode,
|
||||||
group_name: group.groupName,
|
group_name: group.groupName,
|
||||||
member_count: group.memberCount,
|
member_count: group.memberCount,
|
||||||
max_member_count: group.maxMember,
|
max_member_count: group.maxMember,
|
||||||
@ -105,33 +79,33 @@ export class OB11Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static groups(groups: Group[]): OB11Group[] {
|
static groups(groups: Group[]): OB11Group[] {
|
||||||
return groups.map(OB11Entities.group);
|
return groups.map(this.group);
|
||||||
}
|
}
|
||||||
|
|
||||||
static file(peerId: string, file: Exclude<GroupFileInfoUpdateParamType['item'][0]['fileInfo'], undefined>): OB11GroupFile {
|
static file(peerId: string, file: Exclude<GroupFileInfoUpdateParamType['item'][0]['fileInfo'], undefined>): OB11GroupFile {
|
||||||
return {
|
return {
|
||||||
group_id: parseInt(peerId),
|
group_id: +peerId,
|
||||||
file_id: FileNapCatOneBotUUID.encodeModelId({ chatType: 2, peerUid: peerId }, file.fileModelId, file.fileId, file.fileId ?? ''),
|
file_id: FileNapCatOneBotUUID.encodeModelId({ chatType: 2, peerUid: peerId }, file.fileModelId, file.fileId, file.fileId ?? ''),
|
||||||
file_name: file.fileName,
|
file_name: file.fileName,
|
||||||
busid: file.busId,
|
busid: file.busId,
|
||||||
size: parseInt(file.fileSize),
|
size: +file.fileSize,
|
||||||
upload_time: file.uploadTime,
|
upload_time: file.uploadTime,
|
||||||
dead_time: file.deadTime,
|
dead_time: file.deadTime,
|
||||||
modify_time: file.modifyTime,
|
modify_time: file.modifyTime,
|
||||||
download_times: file.downloadTimes,
|
download_times: file.downloadTimes,
|
||||||
uploader: parseInt(file.uploaderUin),
|
uploader: +file.uploaderUin,
|
||||||
uploader_name: file.uploaderName,
|
uploader_name: file.uploaderName,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static folder(peerId: string, folder: Exclude<GroupFileInfoUpdateParamType['item'][0]['folderInfo'], undefined>): OB11GroupFileFolder {
|
static folder(peerId: string, folder: Exclude<GroupFileInfoUpdateParamType['item'][0]['folderInfo'], undefined>): OB11GroupFileFolder {
|
||||||
return {
|
return {
|
||||||
group_id: parseInt(peerId),
|
group_id: +peerId,
|
||||||
folder_id: folder.folderId,
|
folder_id: folder.folderId,
|
||||||
folder: folder.folderId,
|
folder: folder.folderId,
|
||||||
folder_name: folder.folderName,
|
folder_name: folder.folderName,
|
||||||
create_time: folder.createTime,
|
create_time: folder.createTime,
|
||||||
creator: parseInt(folder.createUin),
|
creator: +folder.createUin,
|
||||||
creator_name: folder.creatorName,
|
creator_name: folder.creatorName,
|
||||||
total_file_count: folder.totalFileCount,
|
total_file_count: folder.totalFileCount,
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user