mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-01-17 22:10:29 +00:00
chore: GroupCache
This commit is contained in:
parent
78263d716c
commit
5c877e894b
@ -10,6 +10,9 @@ export class NTQQFriendApi {
|
|||||||
constructor(context: InstanceContext, core: NapCatCore) {
|
constructor(context: InstanceContext, core: NapCatCore) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.core = core;
|
this.core = core;
|
||||||
|
// if (!this.context.basicInfoWrapper.requireMinNTQQBuild('26702')) {
|
||||||
|
// this.getFriends(true);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBuddyV2(refresh = false): Promise<FriendV2[]> {
|
async getBuddyV2(refresh = false): Promise<FriendV2[]> {
|
||||||
|
|||||||
@ -16,12 +16,21 @@ export class NTQQGroupApi {
|
|||||||
core: NapCatCore;
|
core: NapCatCore;
|
||||||
groupCache: Map<string, Group> = new Map<string, Group>();
|
groupCache: Map<string, Group> = new Map<string, Group>();
|
||||||
groupMemberCache: Map<string, Map<string, GroupMember>> = new Map<string, Map<string, GroupMember>>();
|
groupMemberCache: Map<string, Map<string, GroupMember>> = new Map<string, Map<string, GroupMember>>();
|
||||||
|
groups: Group[] = [];
|
||||||
constructor(context: InstanceContext, core: NapCatCore) {
|
constructor(context: InstanceContext, core: NapCatCore) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.core = core;
|
this.core = core;
|
||||||
|
this.initCache().then().catch(context.logger.logError);
|
||||||
|
}
|
||||||
|
async initCache() {
|
||||||
|
this.groups = await this.getGroups();
|
||||||
|
for (const group of this.groups) {
|
||||||
|
this.groupCache.set(group.groupCode, group);
|
||||||
|
let data = await this.getGroupMembers(group.groupCode, 3000);
|
||||||
|
this.groupMemberCache.set(group.groupCode, data);
|
||||||
|
}
|
||||||
|
this.context.logger.logDebug(`加载${this.groups.length}个群组缓存完成`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setGroupAvatar(gc: string, filePath: string) {
|
async setGroupAvatar(gc: string, filePath: string) {
|
||||||
return this.context.session.getGroupService().setHeader(gc, filePath);
|
return this.context.session.getGroupService().setHeader(gc, filePath);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user