chore: NTApi Finish

This commit is contained in:
手瓜一十雪 2024-08-09 15:35:00 +08:00
parent ffe480ad44
commit 7842cd0bc0
2 changed files with 267 additions and 298 deletions

View File

@ -26,8 +26,8 @@ export class NTQQGroupApi {
);
return groupList;
}
async getGroupMemberLatestSendTimeCache(GroupCode: string) {
return this.getGroupMemberLatestSendTime(GroupCode);
async getGroupMemberLatestSendTimeCache(GroupCode: string, uids: string[]) {
return this.getGroupMemberLatestSendTime(GroupCode, uids);
}
/**
* QQ自带数据库获取群成员最后发言时间( )
@ -39,7 +39,7 @@ export class NTQQGroupApi {
* console.log(uin, sendTime);
* }
*/
async getGroupMemberLatestSendTime(GroupCode: string) {
async getGroupMemberLatestSendTime(GroupCode: string, uids: string[]) {
const getdata = async (uid: string) => {
const NTRet = await this.getLatestMsgByUids(GroupCode, [uid]);
if (NTRet.result != 0 && NTRet.msgList.length < 1) {
@ -47,17 +47,13 @@ export class NTQQGroupApi {
}
return { sendUin: NTRet.msgList[0].senderUin, sendTime: NTRet.msgList[0].msgTime };
};
const currentGroupMembers = groupMembers.get(GroupCode);
const PromiseData: Promise<({
sendUin: string;
sendTime: string;
} | undefined)>[] = [];
const ret: Map<string, string> = new Map();
if (!currentGroupMembers) {
return ret;
}
for (const member of currentGroupMembers.values()) {
PromiseData.push(getdata(member.uid).catch(() => undefined));
for (const uid of uids) {
PromiseData.push(getdata(uid).catch(() => undefined));
}
const allRet = await runAllWithTimeout(PromiseData, 2500);
for (const PromiseDo of allRet) {

View File

@ -253,24 +253,6 @@ export class NTQQUserApi {
async getUidByUinV1(Uin: string) {
// 通用转换开始尝试
let uid = (await this.context.session.getUixConvertService().getUid([Uin])).uidInfo.get(Uin);
// Uid 好友转
if (!uid) {
Array.from(friends.values()).forEach((t) => {
if (t.uin == Uin) {
uid = t.uid;
}
});
}
//Uid 群友列表转
if (!uid) {
for (let groupMembersList of groupMembers.values()) {
for (let GroupMember of groupMembersList.values()) {
if (GroupMember.uin == Uin) {
uid = GroupMember.uid;
}
}
}
}
if (!uid) {
let unveifyUid = (await this.getUserDetailInfoByUin(Uin)).info.uid;//从QQ Native 特殊转换 方法三
if (unveifyUid.indexOf("*") == -1) {
@ -287,18 +269,9 @@ export class NTQQUserApi {
[Uid]
);
let uin = ret.uinInfo.get(Uid);
if (!uin) {
//从Buddy缓存获取Uin
Array.from(friends.values()).forEach((t) => {
if (t.uid == Uid) {
uin = t.uin;
}
})
}
if (!uin) {
uin = (await this.getUserDetailInfo(Uid)).uin; //从QQ Native 转换
}
// if (!uin) {
// uin = (await NTQQFriendApi.getFriends(false)).find((t) => { t.uid == Uid })?.uin; //从QQ Native 缓存转换
// }