mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
commit
a4beeba528
@ -4,7 +4,7 @@
|
||||
"name": "LLOneBot",
|
||||
"slug": "LLOneBot",
|
||||
"description": "实现 OneBot 11 和 Satori 协议,用于 QQ 机器人开发",
|
||||
"version": "4.0.8",
|
||||
"version": "4.0.9",
|
||||
"icon": "./icon.webp",
|
||||
"authors": [
|
||||
{
|
||||
|
@ -58,7 +58,7 @@ export class NTQQFriendApi extends Service {
|
||||
return Object.values(data.userSimpleInfos).filter(v => uids.includes(v.uid!))
|
||||
}
|
||||
|
||||
/** uid => uin */
|
||||
/** uid -> uin */
|
||||
async getBuddyIdMap(refresh = false): Promise<Map<string, string>> {
|
||||
const retMap: Map<string, string> = new Map()
|
||||
const data = await invoke<{
|
||||
|
@ -52,7 +52,7 @@ export class NTQQMsgApi extends Service {
|
||||
}
|
||||
|
||||
async getMsgHistory(peer: Peer, msgId: string, cnt: number, queryOrder = false) {
|
||||
// 默认情况下消息时间从旧到新
|
||||
// 默认情况下消息时间从新到旧
|
||||
return await invoke(NTMethod.HISTORY_MSG, [{ peer, msgId, cnt, queryOrder }])
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ export class NTQQMsgApi extends Service {
|
||||
const uniqueId = await this.generateMsgUniqueId(destPeer.chatType)
|
||||
destPeer.guildId = uniqueId
|
||||
const data = await invoke<{ msgList: RawMessage[] }>(
|
||||
'nodeIKernelMsgService/forwardMsg',
|
||||
'nodeIKernelMsgService/forwardMsgWithComment',
|
||||
[{
|
||||
msgIds,
|
||||
srcContact: srcPeer,
|
||||
@ -111,7 +111,8 @@ export class NTQQMsgApi extends Service {
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
},
|
||||
timeout: 3000
|
||||
}
|
||||
)
|
||||
delete destPeer.guildId
|
||||
|
@ -178,7 +178,7 @@ export class NTQQUserApi extends Service {
|
||||
if (uin) return uin
|
||||
uin = (await invoke('nodeIKernelUixConvertService/getUin', [{ uids: [uid] }])).uinInfo.get(uid)
|
||||
if (uin) return uin
|
||||
uin = (await this.ctx.ntFriendApi.getBuddyIdMap(true)).get(uid)
|
||||
uin = (await this.ctx.ntFriendApi.getBuddyIdMap()).get(uid)
|
||||
if (uin) return uin
|
||||
uin = (await this.getUserDetailInfo(uid)).uin
|
||||
return uin
|
||||
|
@ -1,6 +1,9 @@
|
||||
import { Context } from 'cordis'
|
||||
import { Dict } from 'cosmokit'
|
||||
import { getBuildVersion } from '@/common/utils/misc'
|
||||
import { TEMP_DIR } from '@/common/globalVars'
|
||||
import { copyFile } from 'fs/promises'
|
||||
import path from 'node:path'
|
||||
import addon from './external/crychic-win32-x64.node?asset'
|
||||
|
||||
export class Native {
|
||||
@ -18,11 +21,11 @@ export class Native {
|
||||
|
||||
checkVersion() {
|
||||
const version = getBuildVersion()
|
||||
// 27187—27597
|
||||
return version >= 27187 && version < 28060
|
||||
// 27333—27597
|
||||
return version >= 27333 && version < 28060
|
||||
}
|
||||
|
||||
start() {
|
||||
async start() {
|
||||
if (this.crychic) {
|
||||
return
|
||||
}
|
||||
@ -33,7 +36,10 @@ export class Native {
|
||||
return
|
||||
}
|
||||
try {
|
||||
this.crychic = require(addon)
|
||||
const fileName = path.basename(addon)
|
||||
const dest = path.join(TEMP_DIR, fileName)
|
||||
await copyFile(addon, dest)
|
||||
this.crychic = require(dest)
|
||||
this.crychic!.init()
|
||||
} catch (e) {
|
||||
this.ctx.logger.warn('crychic 加载失败', e)
|
||||
|
@ -30,12 +30,12 @@ export class GetGroupMsgHistory extends BaseAction<Payload, Response> {
|
||||
const { count, reverseOrder } = payload
|
||||
const peer = { chatType: ChatType.Group, peerUid: payload.group_id.toString() }
|
||||
let msgList: RawMessage[]
|
||||
if (!payload.message_seq || payload.message_seq === '0') {
|
||||
if (!payload.message_seq || +payload.message_seq === 0) {
|
||||
msgList = (await this.ctx.ntMsgApi.getAioFirstViewLatestMsgs(peer, +count)).msgList
|
||||
} else {
|
||||
const startMsgId = (await this.ctx.store.getMsgInfoByShortId(+payload.message_seq))?.msgId
|
||||
if (!startMsgId) throw new Error(`消息${payload.message_seq}不存在`)
|
||||
msgList = (await this.ctx.ntMsgApi.getMsgHistory(peer, startMsgId, +count)).msgList
|
||||
msgList = (await this.ctx.ntMsgApi.getMsgHistory(peer, startMsgId, +count, true)).msgList
|
||||
}
|
||||
if (!msgList?.length) throw new Error('未找到消息')
|
||||
if (reverseOrder) msgList.reverse()
|
||||
|
@ -17,7 +17,7 @@ export class FriendPoke extends BaseAction<Payload, null> {
|
||||
throw new Error('当前系统平台或架构不支持')
|
||||
}
|
||||
if (!this.ctx.app.native.checkVersion()) {
|
||||
throw new Error(`当前 QQ 版本 ${getBuildVersion()} 不支持,可尝试其他版本 27187—27597`)
|
||||
throw new Error(`当前 QQ 版本 ${getBuildVersion()} 不支持,可尝试其他版本 27333—27597`)
|
||||
}
|
||||
await this.ctx.app.native.sendFriendPoke(+payload.user_id)
|
||||
return null
|
||||
|
@ -19,7 +19,7 @@ export class GroupPoke extends BaseAction<Payload, null> {
|
||||
throw new Error('当前系统平台或架构不支持')
|
||||
}
|
||||
if (!this.ctx.app.native.checkVersion()) {
|
||||
throw new Error(`当前 QQ 版本 ${getBuildVersion()} 不支持,可尝试其他版本 27187—27597`)
|
||||
throw new Error(`当前 QQ 版本 ${getBuildVersion()} 不支持,可尝试其他版本 27333—27597`)
|
||||
}
|
||||
await this.ctx.app.native.sendGroupPoke(+payload.group_id, +payload.user_id)
|
||||
return null
|
||||
|
@ -79,11 +79,14 @@ export namespace OB11Entities {
|
||||
if (msg.chatType === ChatType.Group) {
|
||||
resMsg.sub_type = 'normal'
|
||||
resMsg.group_id = parseInt(msg.peerUin)
|
||||
const member = await ctx.ntGroupApi.getGroupMember(msg.peerUin, msg.senderUid)
|
||||
if (member) {
|
||||
resMsg.sender.role = groupMemberRole(member.role)
|
||||
resMsg.sender.nickname = member.nick
|
||||
resMsg.sender.title = member.memberSpecialTitle ?? ''
|
||||
// 284840486: 合并转发内部
|
||||
if (msg.peerUin !== '284840486') {
|
||||
const member = await ctx.ntGroupApi.getGroupMember(msg.peerUin, msg.senderUid)
|
||||
if (member) {
|
||||
resMsg.sender.role = groupMemberRole(member.role)
|
||||
resMsg.sender.nickname = member.nick
|
||||
resMsg.sender.title = member.memberSpecialTitle ?? ''
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (msg.chatType === ChatType.C2C) {
|
||||
|
@ -129,6 +129,11 @@ async function decodeElement(ctx: Context, data: NT.RawMessage, quoted = false)
|
||||
type: String(faceType),
|
||||
platform: 'llonebot'
|
||||
}))
|
||||
} else if (v.arkElement) {
|
||||
// llonebot:ark
|
||||
buffer.push(h('llonebot:ark', {
|
||||
data: v.arkElement.bytesData
|
||||
}))
|
||||
}
|
||||
}
|
||||
return buffer
|
||||
|
@ -1 +1 @@
|
||||
export const version = '4.0.8'
|
||||
export const version = '4.0.9'
|
||||
|
Loading…
x
Reference in New Issue
Block a user