diff --git a/manifest.json b/manifest.json index 2d3c2c6..799bf15 100644 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ { "manifest_version": 4, "type": "extension", - "name": "LLOneBot v3.26.7", + "name": "LLOneBot v3.27.0", "slug": "LLOneBot", - "description": "使你的NTQQ支持OneBot11协议进行QQ机器人开发, 不支持商店在线更新", - "version": "3.26.7", + "description": "使你的NTQQ支持OneBot11协议进行QQ机器人开发", + "version": "3.27.0", "icon": "./icon.jpg", "authors": [ { diff --git a/src/common/config.ts b/src/common/config.ts index f65c617..3d039a7 100644 --- a/src/common/config.ts +++ b/src/common/config.ts @@ -43,6 +43,7 @@ export class ConfigUtil { enableQOAutoQuote: false } let defaultConfig: Config = { + enableLLOB: true, ob11: ob11Default, heartInterval: 60000, token: '', diff --git a/src/common/types.ts b/src/common/types.ts index df231e1..80f15e0 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -17,6 +17,7 @@ export interface CheckVersion { version: string } export interface Config { + enableLLOB: boolean ob11: OB11Config token?: string heartInterval?: number // ms diff --git a/src/main/main.ts b/src/main/main.ts index 6fc578d..c5245bb 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -13,7 +13,7 @@ import { CHANNEL_UPDATE, } from '../common/channels' import { ob11WebsocketServer } from '../onebot11/server/ws/WebsocketServer' -import { DATA_DIR } from '../common/utils' +import { DATA_DIR, qqPkgInfo } from '../common/utils' import { friendRequests, getFriend, @@ -203,6 +203,10 @@ function onLoad() { async function startReceiveHook() { startHook().then() if (getConfigUtil().getConfig().enablePoke) { + if ( qqPkgInfo.buildVersion > '23873'){ + log(`当前版本${qqPkgInfo.buildVersion}不支持发送戳一戳模块`) + return + } crychic.loadNode() crychic.registerPokeHandler((id, isGroup) => { log(`收到戳一戳消息了!是否群聊:${isGroup},id:${id}`) @@ -435,6 +439,11 @@ function onLoad() { async function start() { log('llonebot pid', process.pid) + const config = getConfigUtil().getConfig() + if (!config.enableLLOB){ + log('LLOneBot 开关设置为关闭,不启动LLOneBot') + return + } llonebotError.otherError = '' startTime = Date.now() dbUtil.getReceivedTempUinMap().then((m) => { @@ -469,7 +478,6 @@ function onLoad() { } - const config = getConfigUtil().getConfig() if (config.ob11.enableHttp) { ob11HTTPServer.start(config.ob11.httpPort) } diff --git a/src/ntqqapi/types/msg.ts b/src/ntqqapi/types/msg.ts index 45fc38b..d81255c 100644 --- a/src/ntqqapi/types/msg.ts +++ b/src/ntqqapi/types/msg.ts @@ -226,6 +226,7 @@ export interface GrayTipElement { content: string } jsonGrayTipElement: { + busiId: number jsonStr: string } } diff --git a/src/onebot11/constructor.ts b/src/onebot11/constructor.ts index abfaad4..643a0f4 100644 --- a/src/onebot11/constructor.ts +++ b/src/onebot11/constructor.ts @@ -24,7 +24,7 @@ import { User, VideoElement, } from '../ntqqapi/types' -import { deleteGroup, getFriend, getGroupMember, selfInfo, tempGroupCodeMap } from '../common/data' +import { deleteGroup, getFriend, getGroupMember, selfInfo, tempGroupCodeMap, uidMaps } from '../common/data' import { EventType } from './event/OB11BaseEvent' import { encodeCQCode } from './cqcode' import { dbUtil } from '../common/db' @@ -47,6 +47,7 @@ import { mFaceCache } from '../ntqqapi/constructor' import { OB11FriendAddNoticeEvent } from './event/notice/OB11FriendAddNoticeEvent' import { OB11FriendRecallNoticeEvent } from './event/notice/OB11FriendRecallNoticeEvent' import { OB11GroupRecallNoticeEvent } from './event/notice/OB11GroupRecallNoticeEvent' +import { OB11GroupPokeEvent } from './event/notice/OB11PokeEvent' let lastRKeyUpdateTime = 0 @@ -490,6 +491,16 @@ export class OB11Constructor { } * */ + if (grayTipElement.jsonGrayTipElement.busiId == 1061) { + //判断业务类型 + //Poke事件 + let pokedetail: any[] = json.items; + //筛选item带有uid的元素 + pokedetail = pokedetail.filter(item => item.uid); + if (pokedetail.length == 2) { + return new OB11GroupPokeEvent(parseInt(msg.peerUid), parseInt((uidMaps[pokedetail[0].uid])!), parseInt((uidMaps[pokedetail[1].uid]))); + } + } const memberUin = json.items[1].param[0] const title = json.items[3].txt log('收到群成员新头衔消息', json) diff --git a/src/onebot11/event/notice/OB11PokeEvent.ts b/src/onebot11/event/notice/OB11PokeEvent.ts index d66813e..1c8f964 100644 --- a/src/onebot11/event/notice/OB11PokeEvent.ts +++ b/src/onebot11/event/notice/OB11PokeEvent.ts @@ -21,10 +21,10 @@ export class OB11FriendPokeEvent extends OB11PokeEvent { export class OB11GroupPokeEvent extends OB11PokeEvent { group_id: number - constructor(group_id: number, user_id: number = 0) { + constructor(group_id: number, user_id: number = 0, target_id: number = 0) { super() this.group_id = group_id - this.target_id = user_id + this.target_id = target_id this.user_id = user_id } } diff --git a/src/renderer/index.ts b/src/renderer/index.ts index 9cdf824..8efc0a0 100644 --- a/src/renderer/index.ts +++ b/src/renderer/index.ts @@ -62,6 +62,13 @@ async function onSettingWindowCreated(view: Element) { SettingButton('请稍候', 'llonebot-update-button', 'secondary'), ), ]), + SettingList([ + SettingItem( + '是否启用 LLOneBot, 重启QQ后生效', + null, + SettingSwitch('enableLLOB', config.enableLLOB, { 'control-display-id': 'config-enableLLOB' }), + )] + ), SettingList([ SettingItem( '启用 HTTP 服务', diff --git a/src/version.ts b/src/version.ts index 678d628..080c347 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const version = '3.26.7' +export const version = '3.27.0'