From 17b44cc0fa8adf25a3a9e18562a5993c43437b39 Mon Sep 17 00:00:00 2001 From: linyuchen Date: Fri, 24 May 2024 17:10:41 +0800 Subject: [PATCH 1/2] refactor: #226 Quick operation reply automatically quotes the original message switch --- src/common/config.ts | 1 + src/common/types.ts | 1 + src/onebot11/action/quick-operation.ts | 15 +++++++++------ src/renderer/index.ts | 5 +++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/common/config.ts b/src/common/config.ts index b6e1f4c..f65c617 100644 --- a/src/common/config.ts +++ b/src/common/config.ts @@ -40,6 +40,7 @@ export class ConfigUtil { enableWsReverse: false, messagePostFormat: 'array', enableHttpHeart: false, + enableQOAutoQuote: false } let defaultConfig: Config = { ob11: ob11Default, diff --git a/src/common/types.ts b/src/common/types.ts index 0ec9008..df231e1 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -10,6 +10,7 @@ export interface OB11Config { enableWsReverse?: boolean messagePostFormat?: 'array' | 'string' enableHttpHeart?: boolean + enableQOAutoQuote: boolean // 快速操作回复自动引用原消息 } export interface CheckVersion { result: boolean diff --git a/src/onebot11/action/quick-operation.ts b/src/onebot11/action/quick-operation.ts index 32f2e6f..fa9c1bf 100644 --- a/src/onebot11/action/quick-operation.ts +++ b/src/onebot11/action/quick-operation.ts @@ -10,6 +10,7 @@ import { ChatType, Group, GroupRequestOperateTypes } from '@/ntqqapi/types' import { getGroup, getUidByUin } from '@/common/data' import { convertMessage2List, createSendElements, sendMsg } from './msg/SendMsg' import { isNull, log } from '@/common/utils' +import { getConfigUtil } from '@/common/config' interface QuickOperationPrivateMessage { @@ -49,8 +50,8 @@ export async function handleQuickOperation(context: QuickOperationEvent, quickAc handleMsg(context as OB11Message, quickAction).then().catch(log) } if (context.post_type === 'request') { - const friendRequest = context as OB11FriendRequestEvent; - const groupRequest = context as OB11GroupRequestEvent; + const friendRequest = context as OB11FriendRequestEvent + const groupRequest = context as OB11GroupRequestEvent if ((friendRequest).request_type === 'friend') { handleFriendRequest(friendRequest, quickAction).then().catch(log) } @@ -64,6 +65,7 @@ async function handleMsg(msg: OB11Message, quickAction: QuickOperationPrivateMes msg = msg as OB11Message const rawMessage = await dbUtil.getMsgByShortId(msg.message_id) const reply = quickAction.reply + const ob11Config = getConfigUtil().getConfig().ob11 let peer: Peer = { chatType: ChatType.friend, peerUid: msg.user_id.toString(), @@ -80,14 +82,15 @@ async function handleMsg(msg: OB11Message, quickAction: QuickOperationPrivateMes } if (reply) { let group: Group = null - let replyMessage: OB11MessageData[] = [ - { + let replyMessage: OB11MessageData[] = [] + if (ob11Config.enableQOAutoQuote) { + replyMessage.push({ type: OB11MessageDataType.reply, data: { id: msg.message_id.toString(), }, - } - ] + }) + } if (msg.message_type == 'group') { group = await getGroup(msg.group_id.toString()) diff --git a/src/renderer/index.ts b/src/renderer/index.ts index bee2b41..9cdf824 100644 --- a/src/renderer/index.ts +++ b/src/renderer/index.ts @@ -171,6 +171,11 @@ async function onSettingWindowCreated(view: Element) { `
`, 'config-musicSignUrl', ), + SettingItem( + '快速操作回复自动引用原消息', + null, + SettingSwitch('ob11.enableQOAutoQuote', config.ob11.enableQOAutoQuote, { 'control-display-id': 'config-ob11-enableQOAutoQuote' }), + ), SettingItem('', null, SettingButton('保存', 'config-ob11-save', 'primary')), ]), SettingList([ From f336317a33d1b26fef3a1a66d2e1b48f84446c99 Mon Sep 17 00:00:00 2001 From: linyuchen Date: Fri, 24 May 2024 17:11:05 +0800 Subject: [PATCH 2/2] chore: version 3.26.2 --- manifest.json | 4 ++-- src/version.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index d041028..c37e147 100644 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ { "manifest_version": 4, "type": "extension", - "name": "LLOneBot v3.26.1", + "name": "LLOneBot v3.26.2", "slug": "LLOneBot", "description": "使你的NTQQ支持OneBot11协议进行QQ机器人开发, 不支持商店在线更新", - "version": "3.26.1", + "version": "3.26.2", "icon": "./icon.jpg", "authors": [ { diff --git a/src/version.ts b/src/version.ts index 0fda212..f7264db 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const version = '3.26.1' +export const version = '3.26.2'