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