Merge pull request #363 from LLOneBot/dev

3.30.2
This commit is contained in:
idranme 2024-08-23 00:30:48 +08:00 committed by GitHub
commit bf72685501
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 27 additions and 17 deletions

View File

@ -4,7 +4,7 @@
"name": "LLOneBot",
"slug": "LLOneBot",
"description": "实现 OneBot 11 协议,用于 QQ 机器人开发",
"version": "3.30.1",
"version": "3.30.2",
"icon": "./icon.webp",
"authors": [
{

View File

@ -5,6 +5,7 @@ import { getSession } from '@/ntqqapi/wrapper'
import { BuddyListReqType, NodeIKernelProfileService } from '../services'
import { NTEventDispatch } from '@/common/utils/EventTask'
import { LimitedHashTable } from '@/common/utils/table'
import { pick } from 'cosmokit'
export class NTQQFriendApi {
/** 大于或等于 26702 应使用 getBuddyV2 */
@ -73,7 +74,7 @@ export class NTQQFriendApi {
} else {
const data = await invoke<{
buddyCategory: CategoryFriend[]
userSimpleInfos: Map<string, SimpleInfo>
userSimpleInfos: Record<string, SimpleInfo>
}>({
className: NTClass.NODE_STORE_API,
methodName: 'getBuddyList',
@ -81,7 +82,11 @@ export class NTQQFriendApi {
cbCmd: ReceiveCmdS.FRIENDS,
afterFirstCmd: false,
})
return Array.from(data.userSimpleInfos.values())
const categoryUids: Map<number, string[]> = new Map()
for (const item of data.buddyCategory) {
categoryUids.set(item.categoryId, item.buddyUids)
}
return Object.values(data.userSimpleInfos).filter(v => v.baseInfo && categoryUids.get(v.baseInfo.categoryId)?.includes(v.uid!))
}
}
@ -102,7 +107,7 @@ export class NTQQFriendApi {
} else {
const data = await invoke<{
buddyCategory: CategoryFriend[]
userSimpleInfos: Map<string, SimpleInfo>
userSimpleInfos: Record<string, SimpleInfo>
}>({
className: NTClass.NODE_STORE_API,
methodName: 'getBuddyList',
@ -110,9 +115,9 @@ export class NTQQFriendApi {
cbCmd: ReceiveCmdS.FRIENDS,
afterFirstCmd: false,
})
data.userSimpleInfos.forEach((value, key) => {
retMap.set(value.uin!, value.uid!)
})
for (const item of Object.values(data.userSimpleInfos)) {
retMap.set(item.uin!, item.uid!)
}
}
return retMap
}
@ -141,7 +146,7 @@ export class NTQQFriendApi {
} else {
const data = await invoke<{
buddyCategory: CategoryFriend[]
userSimpleInfos: Map<string, SimpleInfo>
userSimpleInfos: Record<string, SimpleInfo>
}>({
className: NTClass.NODE_STORE_API,
methodName: 'getBuddyList',
@ -149,15 +154,18 @@ export class NTQQFriendApi {
cbCmd: ReceiveCmdS.FRIENDS,
afterFirstCmd: false,
})
return Array.from(data.userSimpleInfos).map(([key, value]) => {
if (value.baseInfo) {
const category: Map<number, Pick<CategoryFriend, 'buddyUids' | 'categroyName'>> = new Map()
for (const item of data.buddyCategory) {
category.set(item.categoryId, pick(item, ['buddyUids', 'categroyName']))
}
return Object.values(data.userSimpleInfos)
.filter(v => v.baseInfo && category.get(v.baseInfo.categoryId)?.buddyUids.includes(v.uid!))
.map(value => {
return {
...value,
categoryId: value.baseInfo.categoryId,
categroyName: data.buddyCategory.find(e => e.categoryId === value.baseInfo.categoryId)?.categroyName
categroyName: category.get(value.baseInfo.categoryId)?.categroyName
}
}
return value
})
}
}

View File

@ -82,7 +82,8 @@ export interface CategoryFriend {
categroyName: string
categroyMbCount: number
onlineCount: number
buddyList: User[]
buddyList: User[] // V1
buddyUids: string[]
}
export interface CoreInfo {

View File

@ -49,6 +49,7 @@ import { OB11GroupRecallNoticeEvent } from './event/notice/OB11GroupRecallNotice
import { OB11FriendPokeEvent, OB11GroupPokeEvent } from './event/notice/OB11PokeEvent'
import { OB11BaseNoticeEvent } from './event/notice/OB11BaseNoticeEvent'
import { OB11GroupEssenceEvent } from './event/notice/OB11GroupEssenceEvent'
import { omit } from 'cosmokit'
export class OB11Constructor {
static async message(msg: RawMessage): Promise<OB11Message> {
@ -661,7 +662,7 @@ export class OB11Constructor {
for (const friend of friends) {
const sexValue = this.sex(friend.baseInfo.sex!)
data.push({
...friend.baseInfo,
...omit(friend.baseInfo, ['richBuffer']),
...friend.coreInfo,
user_id: parseInt(friend.coreInfo.uin),
nickname: friend.coreInfo.nick,

View File

@ -1 +1 @@
export const version = '3.30.1'
export const version = '3.30.2'