Skip to content

Commit 1798b8c

Browse files
authored
Merge pull request #766 from LLOneBot/dev
chore: update version to 7.12.14
2 parents c76dcf1 + 63cc40c commit 1798b8c

60 files changed

Lines changed: 1028 additions & 866 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

doc/更新日志.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
V7.12.14
2+
更新时间 2026-05-15
3+
4+
* Milky 修复 get_history_messages API 获取包含 ark 的消息时可能报错
5+
6+
=================
17
V7.12.13
28
更新时间 2026-05-05
39

package-dist.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"name":"llonebot-dist","version":"7.12.13","type":"module","description":"","main":"llbot.js","author":"linyuchen","repository":{"type":"git","url":"https://github.com/LLOneBot/LuckyLilliaBot"}}
1+
{"name":"llonebot-dist","version":"7.12.14","type":"module","description":"","main":"llbot.js","author":"linyuchen","repository":{"type":"git","url":"https://github.com/LLOneBot/LuckyLilliaBot"}}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"dependencies": {
2222
"@cordisjs/plugin-logger": "^1.0.2",
2323
"@cordisjs/plugin-timer": "^1.1.1",
24-
"@hono/node-server": "^2.0.0",
24+
"@hono/node-server": "^2.0.2",
2525
"@minatojs/driver-sqlite": "^5.0.3",
2626
"@saltify/milky-types": "^1.2.2",
2727
"@saltify/typeproto": "^0.4.1",
@@ -30,11 +30,11 @@
3030
"compare-versions": "^6.1.1",
3131
"cordis": "^4.0.0-rc.4",
3232
"cosmokit": "^1.8.1",
33-
"fast-xml-parser": "^5.7.2",
33+
"fast-xml-parser": "^5.7.3",
3434
"file-type": "^22.0.1",
3535
"fluent-ffmpeg": "^2.1.3",
3636
"get-port": "^7.2.0",
37-
"hono": "^4.12.15",
37+
"hono": "^4.12.18",
3838
"image-size": "^2.0.2",
3939
"json5": "^2.2.3",
4040
"minato": "^4.0.1",
@@ -55,7 +55,7 @@
5555
"ts-case-convert": "^2.1.0",
5656
"tsx": "^4.21.0",
5757
"typescript": "^6.0.3",
58-
"vite": "^8.0.10",
58+
"vite": "^8.0.11",
5959
"vite-plugin-cp": "^6.0.3",
6060
"vitest": "^4.1.5"
6161
},

src/common/types.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,25 +147,12 @@ export interface CheckVersion {
147147
version: string
148148
}
149149

150-
151150
export interface FileCache {
152-
fileName: string
153-
fileSize: string
154-
msgId: string
155-
peerUid: string
156-
chatType: number
157-
elementId: string
158-
elementType: number
159-
}
160-
161-
export interface FileCacheV2 {
162151
fileName: string
163152
fileSize: string
164153
fileUuid: string
165-
msgId: string
166154
msgTime: number
167-
peerUid: string
168155
chatType: number
169-
elementId: string
170156
elementType: number
157+
md5HexStr: string
171158
}

src/common/utils/file.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { TEMP_DIR } from '../globalVars'
77
import { randomUUID, createHash } from 'node:crypto'
88
import { fileURLToPath } from 'node:url'
99
import { Context } from 'cordis'
10+
import { ChatType, ElementType } from '@/ntqqapi/types'
1011

1112
// 定义一个异步函数来检查文件是否存在
1213
export function checkFileReceived(path: string, timeout: number = 3000): Promise<void> {
@@ -122,7 +123,7 @@ export async function uri2local(ctx: Context, uri: string, needExt?: boolean): P
122123
let filePath = path.join(TEMP_DIR, fileName)
123124
await fsPromise.writeFile(filePath, res.data)
124125
if (needExt) {
125-
const ext = (await ctx.ntFileApi.getFileType(filePath)).ext
126+
const ext = (await getFileType(filePath)).ext
126127
fileName += `.${ext}`
127128
const newPath = `${filePath}.${ext}`
128129
await fsPromise.rename(filePath, newPath)
@@ -141,7 +142,7 @@ export async function uri2local(ctx: Context, uri: string, needExt?: boolean): P
141142
const base64 = uri.replace(/^base64:\/\//, '')
142143
await fsPromise.writeFile(filePath, base64, 'base64')
143144
if (needExt) {
144-
const ext = (await ctx.ntFileApi.getFileType(filePath)).ext
145+
const ext = (await getFileType(filePath)).ext
145146
filename += `.${ext}`
146147
await fsPromise.rename(filePath, `${filePath}.${ext}`)
147148
filePath = `${filePath}.${ext}`
@@ -158,7 +159,7 @@ export async function uri2local(ctx: Context, uri: string, needExt?: boolean): P
158159
let filePath = path.join(TEMP_DIR, filename)
159160
await fsPromise.writeFile(filePath, base64, 'base64')
160161
if (needExt) {
161-
const ext = (await ctx.ntFileApi.getFileType(filePath)).ext
162+
const ext = (await getFileType(filePath)).ext
162163
filename += `.${ext}`
163164
await fsPromise.rename(filePath, `${filePath}.${ext}`)
164165
filePath = `${filePath}.${ext}`
@@ -174,15 +175,21 @@ export async function uri2local(ctx: Context, uri: string, needExt?: boolean): P
174175
fileCache = await ctx.store.getFileCacheByName(uri)
175176
}
176177
if (fileCache?.length) {
177-
const downloadPath = await ctx.ntFileApi.downloadMedia(
178-
fileCache[0].msgId,
179-
fileCache[0].chatType,
180-
fileCache[0].peerUid,
181-
fileCache[0].elementId,
182-
'',
183-
'',
184-
)
185-
return { success: true, errMsg: '', fileName: fileCache[0].fileName, path: downloadPath, isLocal: true }
178+
const isGroup = fileCache[0].chatType === ChatType.Group
179+
let url
180+
if (fileCache[0].elementType === ElementType.Pic) {
181+
const originImageUrl = `/download?appid=${isGroup ? 1407 : 1406}&fileid=${fileCache[0].fileUuid}&spec=0`
182+
url = await ctx.ntFileApi.getImageUrl(originImageUrl, fileCache[0].md5HexStr)
183+
} else if (fileCache[0].elementType === ElementType.Video) {
184+
url = await ctx.ntFileApi.getVideoUrl(fileCache[0].fileUuid, isGroup)
185+
} else if (fileCache[0].elementType === ElementType.Ptt) {
186+
url = await ctx.ntFileApi.getPttUrl(fileCache[0].fileUuid, isGroup)
187+
}
188+
if (url) {
189+
return await uri2local(ctx, url, needExt)
190+
} else {
191+
return { success: false, errMsg: `不支持的文件类型: ${fileCache[0].elementType}`, fileName: '', path: '', isLocal: false }
192+
}
186193
}
187194
}
188195

src/common/utils/misc.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,7 @@ export function uint32ToIPV4Addr(value: number) {
7070
export function sleep(ms = 0) {
7171
return new Promise<void>((resolve) => setTimeout(resolve, ms))
7272
}
73+
74+
export function isHttpUrl(str: string) {
75+
return /^https?:\/\/.+/.test(str)
76+
}

src/main/main.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { Context } from 'cordis'
1717
import { selfInfo, LOG_DIR, TEMP_DIR, dbDir } from '../common/globalVars'
1818
import {
1919
NTQQFileApi,
20-
NTQQFileCacheApi,
2120
NTQQFriendApi,
2221
NTQQGroupApi,
2322
NTLoginApi,
@@ -64,7 +63,6 @@ async function onLoad() {
6463
ctx.plugin(ConfigService)
6564
ctx.plugin(PMHQ)
6665
ctx.plugin(NTQQFileApi)
67-
ctx.plugin(NTQQFileCacheApi)
6866
ctx.plugin(NTQQFriendApi)
6967
ctx.plugin(NTQQGroupApi)
7068
ctx.plugin(NTLoginApi)

src/main/pmhq/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { PMHQBase } from './base'
2-
import { FriendMixin, GroupMixin, MediaMixin, MessageMixin, UserMixin } from './mixins'
2+
import { FriendMixin, GroupMixin, MediaMixin, MessageMixin, SystemMixin, UserMixin } from './mixins'
33

44
export type {
55
PBData,
@@ -49,7 +49,7 @@ function applyMixins<TBase extends Constructor, TMixins extends readonly Mixin<a
4949
/**
5050
* PMHQ 类 - 通过 Mixin 模式组合所有功能
5151
*/
52-
const mixins = [GroupMixin, FriendMixin, MediaMixin, MessageMixin, UserMixin] as const
52+
const mixins = [GroupMixin, FriendMixin, MediaMixin, MessageMixin, UserMixin, SystemMixin] as const
5353
export const PMHQ = applyMixins(PMHQBase, mixins)
5454

5555
declare module 'cordis' {

src/main/pmhq/mixins/friend.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,68 @@ export function FriendMixin<T extends new (...args: any[]) => PMHQBase>(Base: T)
4646
url: `https://${download.downloadDns}/ftn_handler/${download.downloadUrl.toString('hex')}/?fname=${encodeURIComponent(fileName)}`
4747
}
4848
}
49+
50+
async setFriendRequest(targetUid: string, accept: number) {
51+
const body = Oidb.SetFriendRequestReq.encode({
52+
targetUid,
53+
accept,
54+
})
55+
const data = Oidb.Base.encode({
56+
command: 0xb5d,
57+
subCommand: 44,
58+
body,
59+
})
60+
await this.httpSendPB('OidbSvcTrpcTcp.0xb5d_44', data)
61+
}
62+
63+
async setFilteredFriendRequestReq(selfUid: string, requestUid: string) {
64+
const body = Oidb.SetFilteredFriendRequestReq.encode({
65+
selfUid,
66+
requestUid,
67+
})
68+
const data = Oidb.Base.encode({
69+
command: 0xd72,
70+
subCommand: 0,
71+
body,
72+
})
73+
await this.httpSendPB('OidbSvcTrpcTcp.0xd72_0', data)
74+
}
75+
76+
async fetchFriends() {
77+
const body = Oidb.IncPullReq.encode({
78+
reqCount: 500,
79+
flag: 1,
80+
requestBiz: [{
81+
bizType: 1,
82+
bizData: {
83+
extBusi: [102, 103, 20002, 20009, 20031, 20037, 27394]
84+
}
85+
}]
86+
})
87+
const data = Oidb.Base.encode({
88+
command: 0xfd4,
89+
subCommand: 1,
90+
body,
91+
})
92+
const res = await this.httpSendPB('OidbSvcTrpcTcp.0xfd4_1', data)
93+
const oidbRespBody = Oidb.Base.decode(Buffer.from(res.pb, 'hex')).body
94+
return Oidb.IncPullResp.decode(oidbRespBody)
95+
}
96+
97+
async getFriendRecommendContactArk(uin: number) {
98+
const body = Oidb.GetFriendRecommendContactArkReq.encode({
99+
uin,
100+
phoneNumber: '-',
101+
jumpUrl: `mqqapi://card/show_pslcard?src_type=internal&source=sharecard&version=1&uin=${uin}`,
102+
})
103+
const data = Oidb.Base.encode({
104+
command: 0x12b6,
105+
subCommand: 0,
106+
body,
107+
})
108+
const res = await this.httpSendPB('OidbSvcTrpcTcp.0x12b6_0', data)
109+
const oidbRespBody = Oidb.Base.decode(Buffer.from(res.pb, 'hex')).body
110+
return Oidb.GetFriendRecommendContactArkResp.decode(oidbRespBody)
111+
}
49112
}
50113
}

src/main/pmhq/mixins/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export { GroupMixin } from './group'
33
export { MediaMixin } from './media'
44
export { MessageMixin } from './message'
55
export { UserMixin } from './user'
6+
export { SystemMixin } from './system'

0 commit comments

Comments
 (0)