mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
optimize
This commit is contained in:
parent
536999f296
commit
2d354c5eda
@ -33,7 +33,6 @@ export class ConfigUtil {
|
||||
enableWsReverse: false,
|
||||
messagePostFormat: 'array',
|
||||
enableHttpHeart: false,
|
||||
enableQOAutoQuote: false,
|
||||
listenLocalhost: false
|
||||
}
|
||||
const defaultConfig: Config = {
|
||||
|
@ -10,7 +10,11 @@ export interface OB11Config {
|
||||
enableWsReverse?: boolean
|
||||
messagePostFormat?: 'array' | 'string'
|
||||
enableHttpHeart?: boolean
|
||||
enableQOAutoQuote: boolean // 快速操作回复自动引用原消息
|
||||
/**
|
||||
* 快速操作回复自动引用原消息
|
||||
* @deprecated
|
||||
*/
|
||||
enableQOAutoQuote?: boolean
|
||||
listenLocalhost: boolean
|
||||
}
|
||||
|
||||
|
@ -117,17 +117,15 @@ export class NTQQGroupApi extends Service {
|
||||
const type = parseInt(flagitem[2])
|
||||
const session = getSession()
|
||||
if (session) {
|
||||
return session.getGroupService().operateSysNotify(
|
||||
false,
|
||||
{
|
||||
'operateType': operateType, // 2 拒绝
|
||||
'targetMsg': {
|
||||
'seq': seq, // 通知序列号
|
||||
'type': type,
|
||||
'groupCode': groupCode,
|
||||
'postscript': reason || ' ' // 仅传空值可能导致处理失败,故默认给个空格
|
||||
}
|
||||
})
|
||||
return session.getGroupService().operateSysNotify(false, {
|
||||
operateType, // 2 拒绝
|
||||
targetMsg: {
|
||||
seq, // 通知序列号
|
||||
type,
|
||||
groupCode,
|
||||
postscript: reason || ' ' // 仅传空值可能导致处理失败,故默认给个空格
|
||||
}
|
||||
})
|
||||
} else {
|
||||
return await invoke(NTMethod.HANDLE_GROUP_REQUEST, [{
|
||||
doubt: false,
|
||||
|
@ -14,9 +14,10 @@ export default class SetGroupAddRequest extends BaseAction<Payload, null> {
|
||||
protected async _handle(payload: Payload): Promise<null> {
|
||||
const flag = payload.flag.toString()
|
||||
const approve = payload.approve?.toString() !== 'false'
|
||||
await this.ctx.ntGroupApi.handleGroupRequest(flag,
|
||||
await this.ctx.ntGroupApi.handleGroupRequest(
|
||||
flag,
|
||||
approve ? GroupRequestOperateTypes.approve : GroupRequestOperateTypes.reject,
|
||||
payload.reason || ''
|
||||
payload.reason
|
||||
)
|
||||
return null
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ export namespace OB11Entities {
|
||||
|
||||
// 284840486: 合并消息内侧 消息具体定位不到
|
||||
if (!replyMsg && msg.peerUin !== '284840486') {
|
||||
ctx.logger.info('queryMsgs', msgList.map(e => pick(e, ['msgSeq', 'msgRandom'])))
|
||||
ctx.logger.info('queryMsgs', msgList.map(e => pick(e, ['msgSeq', 'msgRandom'])), records.msgRandom)
|
||||
throw new Error('回复消息验证失败')
|
||||
}
|
||||
messageSegment = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { OB11Message, OB11MessageAt, OB11MessageData, OB11MessageDataType } from '../types'
|
||||
import { OB11Message, OB11MessageData, OB11MessageDataType } from '../types'
|
||||
import { OB11FriendRequestEvent } from '../event/request/OB11FriendRequest'
|
||||
import { OB11GroupRequestEvent } from '../event/request/OB11GroupRequest'
|
||||
import { GroupRequestOperateTypes } from '@/ntqqapi/types'
|
||||
@ -6,7 +6,6 @@ import { convertMessage2List, createSendElements, sendMsg, createPeer, CreatePee
|
||||
import { MessageUnique } from '@/common/utils/messageUnique'
|
||||
import { isNullable } from 'cosmokit'
|
||||
import { Context } from 'cordis'
|
||||
import { OB11Config } from '@/common/types'
|
||||
|
||||
interface QuickOperationPrivateMessage {
|
||||
reply?: string
|
||||
@ -57,7 +56,6 @@ export async function handleQuickOperation(ctx: Context, event: QuickOperationEv
|
||||
|
||||
async function handleMsg(ctx: Context, msg: OB11Message, quickAction: QuickOperationPrivateMessage | QuickOperationGroupMessage) {
|
||||
const reply = quickAction.reply
|
||||
const ob11Config: OB11Config = ctx.config
|
||||
let contextMode = CreatePeerMode.Normal
|
||||
if (msg.message_type === 'group') {
|
||||
contextMode = CreatePeerMode.Group
|
||||
@ -67,23 +65,21 @@ async function handleMsg(ctx: Context, msg: OB11Message, quickAction: QuickOpera
|
||||
const peer = await createPeer(ctx, msg, contextMode)
|
||||
if (reply) {
|
||||
let replyMessage: OB11MessageData[] = []
|
||||
if (ob11Config.enableQOAutoQuote) {
|
||||
replyMessage.push({
|
||||
type: OB11MessageDataType.reply,
|
||||
data: {
|
||||
id: msg.message_id.toString(),
|
||||
},
|
||||
})
|
||||
}
|
||||
replyMessage.push({
|
||||
type: OB11MessageDataType.reply,
|
||||
data: {
|
||||
id: msg.message_id.toString(),
|
||||
},
|
||||
})
|
||||
|
||||
if (msg.message_type == 'group') {
|
||||
if ((quickAction as QuickOperationGroupMessage).at_sender) {
|
||||
replyMessage.push({
|
||||
type: 'at',
|
||||
type: OB11MessageDataType.at,
|
||||
data: {
|
||||
qq: msg.user_id.toString(),
|
||||
},
|
||||
} as OB11MessageAt)
|
||||
})
|
||||
}
|
||||
}
|
||||
replyMessage = replyMessage.concat(convertMessage2List(reply, quickAction.auto_escape))
|
||||
@ -130,4 +126,4 @@ async function handleGroupRequest(ctx: Context, request: OB11GroupRequestEvent,
|
||||
quickAction.reason,
|
||||
).catch(e => ctx.logger.error(e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -160,11 +160,6 @@ async function onSettingWindowCreated(view: Element) {
|
||||
`<div class="q-input" style="width:210px;"><input class="q-input__inner" data-config-key="musicSignUrl" type="text" value="${config.musicSignUrl}" placeholder="未设置" /></div>`,
|
||||
'config-musicSignUrl',
|
||||
),
|
||||
SettingItem(
|
||||
'快速操作回复自动引用原消息',
|
||||
null,
|
||||
SettingSwitch('ob11.enableQOAutoQuote', config.ob11.enableQOAutoQuote),
|
||||
),
|
||||
SettingItem(
|
||||
'HTTP、正向 WebSocket 服务仅监听 127.0.0.1',
|
||||
'而不是 0.0.0.0',
|
||||
|
Loading…
x
Reference in New Issue
Block a user