mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
85001a40da | ||
![]() |
867a05c85a | ||
![]() |
d8a63f6561 | ||
![]() |
e9fb9d1b30 | ||
![]() |
b4fc987537 | ||
![]() |
d0ccf53d88 | ||
![]() |
d5ca94569d | ||
![]() |
bf72685501 | ||
![]() |
c07467b670 | ||
![]() |
ea164fb048 |
2
.github/workflows/publish.yml
vendored
2
.github/workflows/publish.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
- name: setup node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
node-version: 20
|
||||
|
||||
- name: install dependenies
|
||||
run: |
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"name": "LLOneBot",
|
||||
"slug": "LLOneBot",
|
||||
"description": "实现 OneBot 11 协议,用于 QQ 机器人开发",
|
||||
"version": "3.30.1",
|
||||
"version": "3.30.4",
|
||||
"icon": "./icon.webp",
|
||||
"authors": [
|
||||
{
|
||||
|
@@ -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,16 +154,19 @@ 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
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -98,6 +98,10 @@ export class NTQQGroupApi {
|
||||
)
|
||||
return notifies
|
||||
} else {
|
||||
invoke({
|
||||
methodName: ReceiveCmdS.GROUP_NOTIFY,
|
||||
classNameIsRegister: true,
|
||||
})
|
||||
return (await invoke<GroupNotifies>({
|
||||
methodName: NTMethod.GET_GROUP_NOTICE,
|
||||
cbCmd: ReceiveCmdS.GROUP_NOTIFY,
|
||||
|
@@ -197,7 +197,7 @@ export class WebApi {
|
||||
let res = '';
|
||||
let resJson;
|
||||
try {
|
||||
res = await RequestUtil.HttpGetText(url, 'GET', '', { 'Cookie': CookieValue });
|
||||
res = await RequestUtil.HttpGetText(url, 'GET', '', { 'Cookie': cookieStr });
|
||||
const match = res.match(/window\.__INITIAL_STATE__=(.*?);/);
|
||||
if (match) {
|
||||
resJson = JSON.parse(match[1].trim());
|
||||
@@ -214,7 +214,8 @@ export class WebApi {
|
||||
}
|
||||
|
||||
let HonorInfo: any = { group_id: groupCode };
|
||||
const CookieValue = (await NTQQUserApi.getCookies('qun.qq.com')).cookies;
|
||||
const cookieObject = await NTQQUserApi.getCookies('qun.qq.com')
|
||||
const cookieStr = Object.entries(cookieObject).map(([key, value]) => `${key}=${value}`).join('; ')
|
||||
|
||||
if (getType === WebHonorType.TALKACTIVE || getType === WebHonorType.ALL) {
|
||||
try {
|
||||
|
@@ -82,7 +82,8 @@ export interface CategoryFriend {
|
||||
categroyName: string
|
||||
categroyMbCount: number
|
||||
onlineCount: number
|
||||
buddyList: User[]
|
||||
buddyList: User[] // V1
|
||||
buddyUids: string[]
|
||||
}
|
||||
|
||||
export interface CoreInfo {
|
||||
|
@@ -15,10 +15,13 @@ export class GetCookies extends BaseAction<Payload, Response> {
|
||||
actionName = ActionName.GetCookies
|
||||
|
||||
protected async _handle(payload: Payload) {
|
||||
if (!payload.domain) {
|
||||
throw '缺少参数 domain'
|
||||
}
|
||||
const cookiesObject = await NTQQUserApi.getCookies(payload.domain)
|
||||
//把获取到的cookiesObject转换成 k=v; 格式字符串拼接在一起
|
||||
const cookies = Object.entries(cookiesObject).map(([key, value]) => `${key}=${value}`).join('; ')
|
||||
const bkn = WebApi.genBkn(cookiesObject.p_skey)
|
||||
const bkn = cookiesObject.skey ? WebApi.genBkn(cookiesObject.skey) : ''
|
||||
return { cookies, bkn }
|
||||
}
|
||||
}
|
||||
|
@@ -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,
|
||||
|
@@ -1 +1 @@
|
||||
export const version = '3.30.1'
|
||||
export const version = '3.30.4'
|
||||
|
Reference in New Issue
Block a user