Merge pull request #415 from LLOneBot/dev

release: 3.32.5
This commit is contained in:
idranme
2024-09-13 18:59:37 +08:00
committed by GitHub
23 changed files with 70 additions and 207 deletions

View File

@@ -7,9 +7,6 @@ body:
attributes:
value: |
欢迎来到 LLOneBot 的 Issue Tracker请填写以下表格来提交 Bug。
在提交新的 Bug 反馈前,请确保您:
* 已经搜索了现有的 issues并且没有找到可以解决您问题的方法
* 不与现有的某一 issue 重复
- type: input
id: system-version
attributes:
@@ -40,8 +37,6 @@ body:
label: OneBot 客户端
description: 连接至 LLOneBot 的客户端版本信息
placeholder: Overflow 2.16.0-2cf7991-SNAPSHOT
validations:
required: true
- type: textarea
id: what-happened
attributes:

View File

@@ -4,7 +4,7 @@
"name": "LLOneBot",
"slug": "LLOneBot",
"description": "实现 OneBot 11 协议,用于 QQ 机器人开发",
"version": "3.32.4",
"version": "3.32.5",
"icon": "./icon.webp",
"authors": [
{

View File

@@ -12,7 +12,7 @@
"deploy-win": "cmd /c \"xcopy /C /S /Y dist\\* %LITELOADERQQNT_PROFILE%\\plugins\\LLOneBot\\\"",
"format": "prettier -cw .",
"check": "tsc",
"compile:proto": "pbjs --no-convert --no-encode --no-verify -t static-module -w es6 -p src/ntqqapi/proto -o src/ntqqapi/proto/compiled.js systemMessage.proto profileLikeTip.proto && pbts -o src/ntqqapi/proto/compiled.d.ts src/ntqqapi/proto/compiled.js"
"compile:proto": "pbjs --no-create --no-convert --no-encode --no-verify -t static-module -w es6 -p src/ntqqapi/proto -o src/ntqqapi/proto/compiled.js systemMessage.proto profileLikeTip.proto && pbts -o src/ntqqapi/proto/compiled.d.ts src/ntqqapi/proto/compiled.js"
},
"author": "",
"license": "MIT",

View File

@@ -35,4 +35,4 @@ const manifest = {
}
}
writeFileSync('manifest.json', JSON.stringify(manifest, null, 2))
writeFileSync('manifest.json', JSON.stringify(manifest, null, 2))

View File

@@ -19,4 +19,4 @@ export const selfInfo: SelfInfo = {
uin: '',
nick: '',
online: true,
}
}

View File

@@ -70,4 +70,4 @@ export interface FileCacheV2 {
chatType: number
elementId: string
elementType: number
}
}

View File

@@ -1,5 +1,5 @@
import { QQLevel } from '@/ntqqapi/types'
import { Dict } from 'cosmokit'
import { Dict, isNullable } from 'cosmokit'
export function isNumeric(str: string) {
return /^\d+$/.test(str)
@@ -32,4 +32,8 @@ export function mergeNewProperties(newObj: Dict, oldObj: Dict) {
}
}
})
}
}
export function filterNullable<T>(array: T[]) {
return array.filter(e => !isNullable(e)) as NonNullable<T>[]
}

2
src/global.d.ts vendored
View File

@@ -6,4 +6,4 @@ declare global {
var LiteLoader: Dict
var authData: Dict | undefined
var navigation: Dict | undefined
}
}

View File

@@ -33,4 +33,4 @@ export default class Log {
enable = input.log!
})
}
}
}

View File

@@ -237,4 +237,4 @@ namespace Core {
}
}
export default Core
export default Core

View File

@@ -173,4 +173,4 @@ export function registerCallHook(
export function removeReceiveHook(id: string) {
const index = receiveHooks.findIndex((h) => h.id === id)
receiveHooks.splice(index, 1)
}
}

View File

@@ -181,4 +181,4 @@ export function invoke<
apiArgs,
)
})
}
}

View File

@@ -34,13 +34,6 @@ export namespace SysMsg {
/** SystemMessage bodyWrapper. */
public bodyWrapper?: (SysMsg.ISystemMessageBodyWrapper|null);
/**
* Creates a new SystemMessage instance using the specified properties.
* @param [properties] Properties to set
* @returns SystemMessage instance
*/
public static create(properties?: SysMsg.ISystemMessage): SysMsg.SystemMessage;
/**
* Decodes a SystemMessage message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
@@ -105,13 +98,6 @@ export namespace SysMsg {
/** SystemMessageHeader uid. */
public uid?: (string|null);
/**
* Creates a new SystemMessageHeader instance using the specified properties.
* @param [properties] Properties to set
* @returns SystemMessageHeader instance
*/
public static create(properties?: SysMsg.ISystemMessageHeader): SysMsg.SystemMessageHeader;
/**
* Decodes a SystemMessageHeader message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
@@ -188,13 +174,6 @@ export namespace SysMsg {
/** SystemMessageMsgSpec other. */
public other: number;
/**
* Creates a new SystemMessageMsgSpec instance using the specified properties.
* @param [properties] Properties to set
* @returns SystemMessageMsgSpec instance
*/
public static create(properties?: SysMsg.ISystemMessageMsgSpec): SysMsg.SystemMessageMsgSpec;
/**
* Decodes a SystemMessageMsgSpec message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
@@ -241,13 +220,6 @@ export namespace SysMsg {
/** SystemMessageBodyWrapper body. */
public body: Uint8Array;
/**
* Creates a new SystemMessageBodyWrapper instance using the specified properties.
* @param [properties] Properties to set
* @returns SystemMessageBodyWrapper instance
*/
public static create(properties?: SysMsg.ISystemMessageBodyWrapper): SysMsg.SystemMessageBodyWrapper;
/**
* Decodes a SystemMessageBodyWrapper message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
@@ -306,13 +278,6 @@ export namespace SysMsg {
/** LikeDetail nickname. */
public nickname: string;
/**
* Creates a new LikeDetail instance using the specified properties.
* @param [properties] Properties to set
* @returns LikeDetail instance
*/
public static create(properties?: SysMsg.ILikeDetail): SysMsg.LikeDetail;
/**
* Decodes a LikeDetail message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
@@ -371,13 +336,6 @@ export namespace SysMsg {
/** LikeMsg detail. */
public detail?: (SysMsg.ILikeDetail|null);
/**
* Creates a new LikeMsg instance using the specified properties.
* @param [properties] Properties to set
* @returns LikeMsg instance
*/
public static create(properties?: SysMsg.ILikeMsg): SysMsg.LikeMsg;
/**
* Decodes a LikeMsg message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
@@ -424,13 +382,6 @@ export namespace SysMsg {
/** ProfileLikeTip msg. */
public msg?: (SysMsg.ILikeMsg|null);
/**
* Creates a new ProfileLikeTip instance using the specified properties.
* @param [properties] Properties to set
* @returns ProfileLikeTip instance
*/
public static create(properties?: SysMsg.IProfileLikeTip): SysMsg.ProfileLikeTip;
/**
* Decodes a ProfileLikeTip message from the specified reader or buffer.
* @param reader Reader or buffer to decode from

View File

@@ -68,18 +68,6 @@ export const SysMsg = $root.SysMsg = (() => {
*/
SystemMessage.prototype.bodyWrapper = null;
/**
* Creates a new SystemMessage instance using the specified properties.
* @function create
* @memberof SysMsg.SystemMessage
* @static
* @param {SysMsg.ISystemMessage=} [properties] Properties to set
* @returns {SysMsg.SystemMessage} SystemMessage instance
*/
SystemMessage.create = function create(properties) {
return new SystemMessage(properties);
};
/**
* Decodes a SystemMessage message from the specified reader or buffer.
* @function decode
@@ -224,18 +212,6 @@ export const SysMsg = $root.SysMsg = (() => {
set: $util.oneOfSetter($oneOfFields)
});
/**
* Creates a new SystemMessageHeader instance using the specified properties.
* @function create
* @memberof SysMsg.SystemMessageHeader
* @static
* @param {SysMsg.ISystemMessageHeader=} [properties] Properties to set
* @returns {SysMsg.SystemMessageHeader} SystemMessageHeader instance
*/
SystemMessageHeader.create = function create(properties) {
return new SystemMessageHeader(properties);
};
/**
* Decodes a SystemMessageHeader message from the specified reader or buffer.
* @function decode
@@ -389,18 +365,6 @@ export const SysMsg = $root.SysMsg = (() => {
*/
SystemMessageMsgSpec.prototype.other = 0;
/**
* Creates a new SystemMessageMsgSpec instance using the specified properties.
* @function create
* @memberof SysMsg.SystemMessageMsgSpec
* @static
* @param {SysMsg.ISystemMessageMsgSpec=} [properties] Properties to set
* @returns {SysMsg.SystemMessageMsgSpec} SystemMessageMsgSpec instance
*/
SystemMessageMsgSpec.create = function create(properties) {
return new SystemMessageMsgSpec(properties);
};
/**
* Decodes a SystemMessageMsgSpec message from the specified reader or buffer.
* @function decode
@@ -517,18 +481,6 @@ export const SysMsg = $root.SysMsg = (() => {
*/
SystemMessageBodyWrapper.prototype.body = $util.newBuffer([]);
/**
* Creates a new SystemMessageBodyWrapper instance using the specified properties.
* @function create
* @memberof SysMsg.SystemMessageBodyWrapper
* @static
* @param {SysMsg.ISystemMessageBodyWrapper=} [properties] Properties to set
* @returns {SysMsg.SystemMessageBodyWrapper} SystemMessageBodyWrapper instance
*/
SystemMessageBodyWrapper.create = function create(properties) {
return new SystemMessageBodyWrapper(properties);
};
/**
* Decodes a SystemMessageBodyWrapper message from the specified reader or buffer.
* @function decode
@@ -643,18 +595,6 @@ export const SysMsg = $root.SysMsg = (() => {
*/
LikeDetail.prototype.nickname = "";
/**
* Creates a new LikeDetail instance using the specified properties.
* @function create
* @memberof SysMsg.LikeDetail
* @static
* @param {SysMsg.ILikeDetail=} [properties] Properties to set
* @returns {SysMsg.LikeDetail} LikeDetail instance
*/
LikeDetail.create = function create(properties) {
return new LikeDetail(properties);
};
/**
* Decodes a LikeDetail message from the specified reader or buffer.
* @function decode
@@ -777,18 +717,6 @@ export const SysMsg = $root.SysMsg = (() => {
*/
LikeMsg.prototype.detail = null;
/**
* Creates a new LikeMsg instance using the specified properties.
* @function create
* @memberof SysMsg.LikeMsg
* @static
* @param {SysMsg.ILikeMsg=} [properties] Properties to set
* @returns {SysMsg.LikeMsg} LikeMsg instance
*/
LikeMsg.create = function create(properties) {
return new LikeMsg(properties);
};
/**
* Decodes a LikeMsg message from the specified reader or buffer.
* @function decode
@@ -893,18 +821,6 @@ export const SysMsg = $root.SysMsg = (() => {
*/
ProfileLikeTip.prototype.msg = null;
/**
* Creates a new ProfileLikeTip instance using the specified properties.
* @function create
* @memberof SysMsg.ProfileLikeTip
* @static
* @param {SysMsg.IProfileLikeTip=} [properties] Properties to set
* @returns {SysMsg.ProfileLikeTip} ProfileLikeTip instance
*/
ProfileLikeTip.create = function create(properties) {
return new ProfileLikeTip(properties);
};
/**
* Decodes a ProfileLikeTip message from the specified reader or buffer.
* @function decode

View File

@@ -282,9 +282,23 @@ export interface PicElement {
}
export enum GrayTipElementSubType {
RECALL = 1,
INVITE_NEW_MEMBER = 12,
MEMBER_NEW_TITLE = 17,
REVOKE = 1,
PROCLAMATION = 2,
EMOJIREPLY = 3,
GROUP = 4,
BUDDY = 5,
FEED = 6,
ESSENCE = 7,
GROUPNOTIFY = 8,
BUDDYNOTIFY = 9,
FILE = 10,
FEEDCHANNELMSG = 11,
XMLMSG = 12,
LOCALMSG = 13,
BLOCK = 14,
AIOOP = 15,
WALLET = 16,
JSON = 17,
}
export interface GrayTipElement {
@@ -541,4 +555,4 @@ export interface MessageElement {
taskTopMsgElement?: unknown
recommendedMsgElement?: unknown
actionBarElement?: unknown
}
}

View File

@@ -78,4 +78,4 @@ Process.dlopen = function (module: Dict, filename: string, flags = constants.dlo
export function getSession() {
return wrapperApi['NodeIQQNTWrapperSession']
}
}

View File

@@ -3,6 +3,7 @@ import { OB11ForwardMessage } from '../../types'
import { OB11Entities } from '../../entities'
import { ActionName } from '../types'
import { MessageUnique } from '@/common/utils/messageUnique'
import { filterNullable } from '@/common/utils/misc'
interface Payload {
message_id: string // long msg idgocq
@@ -33,19 +34,21 @@ export class GetForwardMsg extends BaseAction<Payload, Response> {
const messages = await Promise.all(
msgList.map(async (msg) => {
const resMsg = await OB11Entities.message(this.ctx, msg)
if (!resMsg) return
resMsg.message_id = MessageUnique.createMsg({
chatType: msg.chatType,
peerUid: msg.peerUid,
}, msg.msgId)
return resMsg
}),
})
)
const forwardMessages = messages.map(v => {
const msg = v as Partial<OB11ForwardMessage>
msg.content = msg.message
delete msg.message
return msg as OB11ForwardMessage
})
const forwardMessages = filterNullable(messages)
.map(v => {
const msg = v as Partial<OB11ForwardMessage>
msg.content = msg.message
delete msg.message
return msg as OB11ForwardMessage
})
return { messages: forwardMessages }
}
}

View File

@@ -5,6 +5,7 @@ import { ChatType } from '@/ntqqapi/types'
import { OB11Entities } from '../../entities'
import { RawMessage } from '@/ntqqapi/types'
import { MessageUnique } from '@/common/utils/messageUnique'
import { filterNullable } from '@/common/utils/misc'
interface Payload {
group_id: number | string
@@ -41,6 +42,6 @@ export class GetGroupMsgHistory extends BaseAction<Payload, Response> {
})
)
const ob11MsgList = await Promise.all(msgList.map((msg) => OB11Entities.message(this.ctx, msg)))
return { messages: ob11MsgList }
return { messages: filterNullable(ob11MsgList) }
}
}

View File

@@ -15,12 +15,12 @@ class GetMsg extends BaseAction<PayloadType, OB11Message> {
protected async _handle(payload: PayloadType) {
if (!payload.message_id) {
throw '参数message_id不能为空'
throw new Error('参数message_id不能为空')
}
const msgShortId = MessageUnique.getShortIdByMsgId(payload.message_id.toString())
const msgIdWithPeer = await MessageUnique.getMsgIdAndPeerByShortId(msgShortId || +payload.message_id)
if (!msgIdWithPeer) {
throw ('消息不存在')
throw new Error('消息不存在')
}
const peer = {
guildId: '',
@@ -29,6 +29,9 @@ class GetMsg extends BaseAction<PayloadType, OB11Message> {
}
const msg = this.adapter.getMsgCache(msgIdWithPeer.MsgId) ?? (await this.ctx.ntMsgApi.getMsgsByMsgId(peer, [msgIdWithPeer.MsgId])).msgList[0]
const retMsg = await OB11Entities.message(this.ctx, msg)
if (!retMsg) {
throw new Error('消息为空')
}
retMsg.message_id = MessageUnique.createMsg(peer, msg.msgId)!
retMsg.message_seq = retMsg.message_id
retMsg.real_id = retMsg.message_id

View File

@@ -195,6 +195,9 @@ class OneBot11Adapter extends Service {
OB11Entities.message(this.ctx, message)
.then((msg) => {
if (!msg) {
return
}
if (!this.config.debug && msg.message.length === 0) {
return
}
@@ -440,4 +443,4 @@ namespace OneBot11Adapter {
}
}
export default OneBot11Adapter
export default OneBot11Adapter

View File

@@ -49,7 +49,8 @@ import { pathToFileURL } from 'node:url'
import OneBot11Adapter from './adapter'
export namespace OB11Entities {
export async function message(ctx: Context, msg: RawMessage): Promise<OB11Message> {
export async function message(ctx: Context, msg: RawMessage): Promise<OB11Message | undefined> {
if (!msg.senderUin || msg.senderUin === '0') return //跳过空消息
const {
debug,
messagePostFormat,
@@ -57,14 +58,14 @@ export namespace OB11Entities {
const selfUin = selfInfo.uin
const resMsg: OB11Message = {
self_id: parseInt(selfUin),
user_id: parseInt(msg.senderUin!),
user_id: parseInt(msg.senderUin),
time: parseInt(msg.msgTime) || Date.now(),
message_id: msg.msgShortId!,
real_id: msg.msgShortId!,
message_seq: msg.msgShortId!,
message_type: msg.chatType === ChatType.group ? 'group' : 'private',
sender: {
user_id: parseInt(msg.senderUin!),
user_id: parseInt(msg.senderUin),
nickname: msg.sendNickName,
card: msg.sendMemberName ?? '',
},
@@ -81,7 +82,7 @@ export namespace OB11Entities {
if (msg.chatType === ChatType.group) {
resMsg.sub_type = 'normal'
resMsg.group_id = parseInt(msg.peerUin)
const member = await ctx.ntGroupApi.getGroupMember(msg.peerUin, msg.senderUin!)
const member = await ctx.ntGroupApi.getGroupMember(msg.peerUin, msg.senderUin)
if (member) {
resMsg.sender.role = groupMemberRole(member.role)
resMsg.sender.nickname = member.nick
@@ -373,11 +374,10 @@ export namespace OB11Entities {
}
for (const element of msg.elements) {
if (element.grayTipElement) {
if (element.grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE) {
const json = JSON.parse(element.grayTipElement.jsonGrayTipElement.jsonStr)
if (element.grayTipElement.jsonGrayTipElement.busiId == 1061) {
//判断业务类型
//Poke事件
const { grayTipElement } = element
if (grayTipElement.subElementType === GrayTipElementSubType.JSON) {
const json = JSON.parse(grayTipElement.jsonGrayTipElement.jsonStr)
if (grayTipElement.jsonGrayTipElement.busiId === 1061) {
const pokedetail: Dict[] = json.items
//筛选item带有uid的元素
const poke_uid = pokedetail.filter(item => item.uid)
@@ -389,7 +389,6 @@ export namespace OB11Entities {
)
}
}
//下面得改 上面也是错的grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE
}
}
}
@@ -543,7 +542,7 @@ export namespace OB11Entities {
}
if (
grayTipElement.subElementType == GrayTipElementSubType.INVITE_NEW_MEMBER &&
grayTipElement.subElementType == GrayTipElementSubType.XMLMSG &&
xmlElement?.templId == '10179'
) {
ctx.logger.info('收到新人被邀请进群消息', grayTipElement)
@@ -563,35 +562,9 @@ export namespace OB11Entities {
}
}
}
else if (grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE) {
else if (grayTipElement.subElementType == GrayTipElementSubType.JSON) {
const json = JSON.parse(grayTipElement.jsonGrayTipElement.jsonStr)
/*
{
align: 'center',
items: [
{ txt: '恭喜', type: 'nor' },
{
col: '3',
jp: '5',
param: ["QQ号"],
txt: '林雨辰',
type: 'url'
},
{ txt: '获得群主授予的', type: 'nor' },
{
col: '3',
jp: '',
txt: '好好好',
type: 'url'
},
{ txt: '头衔', type: 'nor' }
]
}
* */
if (grayTipElement.jsonGrayTipElement.busiId == 1061) {
//判断业务类型
//Poke事件
const pokedetail: Dict[] = json.items
//筛选item带有uid的元素
const poke_uid = pokedetail.filter(item => item.uid)
@@ -653,7 +626,7 @@ export namespace OB11Entities {
shortId: number
): Promise<OB11FriendRecallNoticeEvent | OB11GroupRecallNoticeEvent | undefined> {
const msgElement = msg.elements.find(
(element) => element.grayTipElement?.subElementType === GrayTipElementSubType.RECALL,
(element) => element.grayTipElement?.subElementType === GrayTipElementSubType.REVOKE,
)
if (!msgElement) {
return

View File

@@ -1,7 +1,7 @@
export const iconSvg = `
<?xml version="2.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="50px" y="10px" width="262px" height="150" viewBox="0 0 212 262" enable-background="new 0 0 212 262" xml:space="preserve">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="50px" y="10px" width="262px" height="150" viewBox="0 0 212 262" enable-background="new 0 0 212 262" xml:space="preserve">
<image id="image0" width="212" height="210" x="0" y="-20" transform="rotate(180, 100, 100)"
xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANQAAAEGCAYAAAAdX7uIAAAAIGNIUk0AAHomAACAhAAA+gAAAIDo
AAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAADsMAAA7DAcdv

View File

@@ -1 +1 @@
export const version = '3.32.4'
export const version = '3.32.5'