This commit is contained in:
idranme 2024-10-13 23:48:22 +08:00
parent dbd71d4376
commit 4ced7fa3cf
4 changed files with 20 additions and 11 deletions

View File

@ -1,6 +1,9 @@
import { Context } from 'cordis' import { Context } from 'cordis'
import { Dict } from 'cosmokit' import { Dict } from 'cosmokit'
import { getBuildVersion } from '@/common/utils/misc' 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' import addon from './external/crychic-win32-x64.node?asset'
export class Native { export class Native {
@ -18,11 +21,11 @@ export class Native {
checkVersion() { checkVersion() {
const version = getBuildVersion() const version = getBuildVersion()
// 27187—27597 // 27333—27597
return version >= 27187 && version < 28060 return version >= 27333 && version < 28060
} }
start() { async start() {
if (this.crychic) { if (this.crychic) {
return return
} }
@ -33,7 +36,10 @@ export class Native {
return return
} }
try { 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() this.crychic!.init()
} catch (e) { } catch (e) {
this.ctx.logger.warn('crychic 加载失败', e) this.ctx.logger.warn('crychic 加载失败', e)

View File

@ -17,7 +17,7 @@ export class FriendPoke extends BaseAction<Payload, null> {
throw new Error('当前系统平台或架构不支持') throw new Error('当前系统平台或架构不支持')
} }
if (!this.ctx.app.native.checkVersion()) { 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) await this.ctx.app.native.sendFriendPoke(+payload.user_id)
return null return null

View File

@ -19,7 +19,7 @@ export class GroupPoke extends BaseAction<Payload, null> {
throw new Error('当前系统平台或架构不支持') throw new Error('当前系统平台或架构不支持')
} }
if (!this.ctx.app.native.checkVersion()) { 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) await this.ctx.app.native.sendGroupPoke(+payload.group_id, +payload.user_id)
return null return null

View File

@ -79,6 +79,8 @@ export namespace OB11Entities {
if (msg.chatType === ChatType.Group) { if (msg.chatType === ChatType.Group) {
resMsg.sub_type = 'normal' resMsg.sub_type = 'normal'
resMsg.group_id = parseInt(msg.peerUin) resMsg.group_id = parseInt(msg.peerUin)
// 284840486: 合并转发内部
if (msg.peerUin !== '284840486') {
const member = await ctx.ntGroupApi.getGroupMember(msg.peerUin, msg.senderUid) const member = await ctx.ntGroupApi.getGroupMember(msg.peerUin, msg.senderUid)
if (member) { if (member) {
resMsg.sender.role = groupMemberRole(member.role) resMsg.sender.role = groupMemberRole(member.role)
@ -86,6 +88,7 @@ export namespace OB11Entities {
resMsg.sender.title = member.memberSpecialTitle ?? '' resMsg.sender.title = member.memberSpecialTitle ?? ''
} }
} }
}
else if (msg.chatType === ChatType.C2C) { else if (msg.chatType === ChatType.C2C) {
resMsg.sub_type = 'friend' resMsg.sub_type = 'friend'
resMsg.sender.nickname = (await ctx.ntUserApi.getUserSimpleInfo(msg.senderUid)).nick resMsg.sender.nickname = (await ctx.ntUserApi.getUserSimpleInfo(msg.senderUid)).nick