mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 13:05:09 +00:00
Optimize emoji likes fetching logic
Adjusts the pagination logic to fetch only the required number of pages based on the requested count. Trims the result list to the specified count if provided, improving efficiency and accuracy.
This commit is contained in:
@@ -49,8 +49,8 @@ export class GetEmojiLikes extends OneBotAction<PayloadType, ReturnType> {
|
|||||||
const emojiType = payload.emoji_type ?? (payload.emoji_id.length > 3 ? '2' : '1');
|
const emojiType = payload.emoji_type ?? (payload.emoji_id.length > 3 ? '2' : '1');
|
||||||
const emojiLikeList: Array<{ user_id: string; nick_name: string; }> = [];
|
const emojiLikeList: Array<{ user_id: string; nick_name: string; }> = [];
|
||||||
let cookie = '';
|
let cookie = '';
|
||||||
|
let needFetchCount = payload.count == 0 ? 200 : Math.ceil(payload.count / 15);
|
||||||
for (let page = 0; page < 200; page++) {
|
for (let page = 0; page < needFetchCount; page++) {
|
||||||
const res = await this.core.apis.MsgApi.getMsgEmojiLikesList(
|
const res = await this.core.apis.MsgApi.getMsgEmojiLikesList(
|
||||||
peer, msg.msgSeq, payload.emoji_id.toString(), emojiType, cookie, 15
|
peer, msg.msgSeq, payload.emoji_id.toString(), emojiType, cookie, 15
|
||||||
);
|
);
|
||||||
@@ -64,7 +64,10 @@ export class GetEmojiLikes extends OneBotAction<PayloadType, ReturnType> {
|
|||||||
if (res.isLastPage || !res.cookie) break;
|
if (res.isLastPage || !res.cookie) break;
|
||||||
cookie = res.cookie;
|
cookie = res.cookie;
|
||||||
}
|
}
|
||||||
|
// 切断多余部分
|
||||||
|
if (payload.count > 0) {
|
||||||
|
emojiLikeList.splice(payload.count);
|
||||||
|
}
|
||||||
return { emoji_like_list: emojiLikeList };
|
return { emoji_like_list: emojiLikeList };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user