Compare commits

..

14 Commits

Author SHA1 Message Date
idranme
b03bcf9a7c Merge pull request #415 from LLOneBot/dev
release: 3.32.5
2024-09-13 18:59:37 +08:00
idranme
d4f9629af2 chore: v3.32.5 2024-09-13 18:54:56 +08:00
idranme
6d47e2ee80 chore 2024-09-13 18:52:45 +08:00
idranme
506bddb21a chore: style 2024-09-13 17:30:56 +08:00
idranme
91c689baf8 fix 2024-09-13 14:56:30 +08:00
idranme
b7938aaab8 refactor 2024-09-12 22:39:14 +08:00
idranme
b1a892cf4e chore 2024-09-12 18:29:18 +08:00
idranme
9284fc7e8a Merge pull request #413 from LLOneBot/dev
3.32.4
2024-09-12 18:14:23 +08:00
idranme
ceb063143a chore: v3.32.4 2024-09-12 18:11:01 +08:00
idranme
ed55a5a54c optimize 2024-09-12 17:52:21 +08:00
idranme
2c4fdbfa6a fix: upload_group_file API 2024-09-12 16:46:38 +08:00
idranme
1132495eb3 fix: check for updates 2024-09-12 01:11:17 +08:00
idranme
2ac2c68435 chore 2024-09-11 22:13:11 +08:00
idranme
6477366ba6 chore
chore
2024-09-11 21:35:50 +08:00
25 changed files with 110 additions and 1421 deletions

View File

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

View File

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

View File

@@ -12,7 +12,7 @@
"deploy-win": "cmd /c \"xcopy /C /S /Y dist\\* %LITELOADERQQNT_PROFILE%\\plugins\\LLOneBot\\\"", "deploy-win": "cmd /c \"xcopy /C /S /Y dist\\* %LITELOADERQQNT_PROFILE%\\plugins\\LLOneBot\\\"",
"format": "prettier -cw .", "format": "prettier -cw .",
"check": "tsc", "check": "tsc",
"compile:proto": "pbjs -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": "", "author": "",
"license": "MIT", "license": "MIT",

View File

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

View File

@@ -5,20 +5,22 @@ import { version } from '../../version'
import { copyFolder, log, fetchFile } from '.' import { copyFolder, log, fetchFile } from '.'
import { PLUGIN_DIR, TEMP_DIR } from '../globalVars' import { PLUGIN_DIR, TEMP_DIR } from '../globalVars'
const downloadMirrorHosts = ['https://mirror.ghproxy.com/'] const downloadMirrorHosts = ['https://ghp.ci/']
const checkVersionMirrorHosts = ['https://kkgithub.com'] const releasesMirrorHosts = ['https://kkgithub.com']
export async function checkNewVersion() { export async function checkNewVersion() {
const latestVersionText = await getRemoteVersion() const latestVersionText = await getRemoteVersion()
const latestVersion = latestVersionText.split('.') const latestVersion = latestVersionText.split('.')
//log('llonebot last version', latestVersion) log('LLOneBot latest version', latestVersion)
const currentVersion: string[] = version.split('.') const currentVersion = version.split('.')
//log('llonebot current version', currentVersion) //log('llonebot current version', currentVersion)
for (const k of [0, 1, 2]) { for (const k of [0, 1, 2]) {
if (parseInt(latestVersion[k]) > parseInt(currentVersion[k])) { const latest = parseInt(latestVersion[k])
const current = parseInt(currentVersion[k])
if (latest > current) {
log('') log('')
return { result: true, version: latestVersionText } return { result: true, version: latestVersionText }
} else if (parseInt(latestVersion[k]) < parseInt(currentVersion[k])) { } else if (latest < current) {
break break
} }
} }
@@ -28,7 +30,7 @@ export async function checkNewVersion() {
export async function upgradeLLOneBot() { export async function upgradeLLOneBot() {
const latestVersion = await getRemoteVersion() const latestVersion = await getRemoteVersion()
if (latestVersion && latestVersion != '') { if (latestVersion && latestVersion != '') {
const downloadUrl = 'https://github.com/LLOneBot/LLOneBot/releases/download/v' + latestVersion + '/LLOneBot.zip' const downloadUrl = `https://github.com/LLOneBot/LLOneBot/releases/download/v${latestVersion}/LLOneBot.zip`
const filePath = path.join(TEMP_DIR, './update-' + latestVersion + '.zip') const filePath = path.join(TEMP_DIR, './update-' + latestVersion + '.zip')
let downloadSuccess = false let downloadSuccess = false
// 多镜像下载 // 多镜像下载
@@ -73,26 +75,34 @@ export async function upgradeLLOneBot() {
} }
export async function getRemoteVersion() { export async function getRemoteVersion() {
let Version = '' for (const mirror of releasesMirrorHosts) {
for (let i = 0; i < checkVersionMirrorHosts.length; i++) { const version = await getRemoteVersionByReleasesMirror(mirror)
const mirrorGithub = checkVersionMirrorHosts[i] if (version) {
const tVersion = await getRemoteVersionByMirror(mirrorGithub) return version
if (tVersion && tVersion != '') { }
Version = tVersion }
break for (const mirror of downloadMirrorHosts) {
const version = await getRemoteVersionByDownloadMirror(mirror)
if (version) {
return version
} }
} }
return Version
}
export async function getRemoteVersionByMirror(mirrorGithub: string) {
let releasePage = 'error'
try {
releasePage = (await fetchFile(mirrorGithub + '/LLOneBot/LLOneBot/releases')).data.toString()
// log("releasePage", releasePage);
if (releasePage === 'error') return ''
return releasePage.match(new RegExp('(?<=(tag/v)).*?(?=("))'))?.[0]
} catch { }
return '' return ''
} }
export async function getRemoteVersionByDownloadMirror(mirrorGithub: string) {
try {
const source = 'https://raw.githubusercontent.com/LLOneBot/LLOneBot/main/src/version.ts'
const page = (await fetchFile(mirrorGithub + source)).data.toString()
return page.match(/(\d+\.\d+\.\d+)/)?.[0]
} catch (e) {
log(e?.toString())
}
}
export async function getRemoteVersionByReleasesMirror(mirrorGithub: string) {
try {
const page = (await fetchFile(mirrorGithub + '/LLOneBot/LLOneBot/releases')).data.toString()
return page.match(new RegExp('(?<=(tag/v)).*?(?=("))'))?.[0]
} catch { }
}

View File

@@ -34,29 +34,6 @@ export namespace SysMsg {
/** SystemMessage bodyWrapper. */ /** SystemMessage bodyWrapper. */
public bodyWrapper?: (SysMsg.ISystemMessageBodyWrapper|null); 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;
/**
* Encodes the specified SystemMessage message. Does not implicitly {@link SysMsg.SystemMessage.verify|verify} messages.
* @param message SystemMessage message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(message: SysMsg.ISystemMessage, writer?: $protobuf.Writer): $protobuf.Writer;
/**
* Encodes the specified SystemMessage message, length delimited. Does not implicitly {@link SysMsg.SystemMessage.verify|verify} messages.
* @param message SystemMessage message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encodeDelimited(message: SysMsg.ISystemMessage, writer?: $protobuf.Writer): $protobuf.Writer;
/** /**
* Decodes a SystemMessage message from the specified reader or buffer. * Decodes a SystemMessage message from the specified reader or buffer.
* @param reader Reader or buffer to decode from * @param reader Reader or buffer to decode from
@@ -76,34 +53,6 @@ export namespace SysMsg {
*/ */
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.SystemMessage; public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.SystemMessage;
/**
* Verifies a SystemMessage message.
* @param message Plain object to verify
* @returns `null` if valid, otherwise the reason why it is not
*/
public static verify(message: { [k: string]: any }): (string|null);
/**
* Creates a SystemMessage message from a plain object. Also converts values to their respective internal types.
* @param object Plain object
* @returns SystemMessage
*/
public static fromObject(object: { [k: string]: any }): SysMsg.SystemMessage;
/**
* Creates a plain object from a SystemMessage message. Also converts values to other types if specified.
* @param message SystemMessage
* @param [options] Conversion options
* @returns Plain object
*/
public static toObject(message: SysMsg.SystemMessage, options?: $protobuf.IConversionOptions): { [k: string]: any };
/**
* Converts this SystemMessage to JSON.
* @returns JSON object
*/
public toJSON(): { [k: string]: any };
/** /**
* Gets the default type url for SystemMessage * Gets the default type url for SystemMessage
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
@@ -149,29 +98,6 @@ export namespace SysMsg {
/** SystemMessageHeader uid. */ /** SystemMessageHeader uid. */
public uid?: (string|null); 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;
/**
* Encodes the specified SystemMessageHeader message. Does not implicitly {@link SysMsg.SystemMessageHeader.verify|verify} messages.
* @param message SystemMessageHeader message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(message: SysMsg.ISystemMessageHeader, writer?: $protobuf.Writer): $protobuf.Writer;
/**
* Encodes the specified SystemMessageHeader message, length delimited. Does not implicitly {@link SysMsg.SystemMessageHeader.verify|verify} messages.
* @param message SystemMessageHeader message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encodeDelimited(message: SysMsg.ISystemMessageHeader, writer?: $protobuf.Writer): $protobuf.Writer;
/** /**
* Decodes a SystemMessageHeader message from the specified reader or buffer. * Decodes a SystemMessageHeader message from the specified reader or buffer.
* @param reader Reader or buffer to decode from * @param reader Reader or buffer to decode from
@@ -191,34 +117,6 @@ export namespace SysMsg {
*/ */
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.SystemMessageHeader; public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.SystemMessageHeader;
/**
* Verifies a SystemMessageHeader message.
* @param message Plain object to verify
* @returns `null` if valid, otherwise the reason why it is not
*/
public static verify(message: { [k: string]: any }): (string|null);
/**
* Creates a SystemMessageHeader message from a plain object. Also converts values to their respective internal types.
* @param object Plain object
* @returns SystemMessageHeader
*/
public static fromObject(object: { [k: string]: any }): SysMsg.SystemMessageHeader;
/**
* Creates a plain object from a SystemMessageHeader message. Also converts values to other types if specified.
* @param message SystemMessageHeader
* @param [options] Conversion options
* @returns Plain object
*/
public static toObject(message: SysMsg.SystemMessageHeader, options?: $protobuf.IConversionOptions): { [k: string]: any };
/**
* Converts this SystemMessageHeader to JSON.
* @returns JSON object
*/
public toJSON(): { [k: string]: any };
/** /**
* Gets the default type url for SystemMessageHeader * Gets the default type url for SystemMessageHeader
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
@@ -276,29 +174,6 @@ export namespace SysMsg {
/** SystemMessageMsgSpec other. */ /** SystemMessageMsgSpec other. */
public other: number; 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;
/**
* Encodes the specified SystemMessageMsgSpec message. Does not implicitly {@link SysMsg.SystemMessageMsgSpec.verify|verify} messages.
* @param message SystemMessageMsgSpec message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(message: SysMsg.ISystemMessageMsgSpec, writer?: $protobuf.Writer): $protobuf.Writer;
/**
* Encodes the specified SystemMessageMsgSpec message, length delimited. Does not implicitly {@link SysMsg.SystemMessageMsgSpec.verify|verify} messages.
* @param message SystemMessageMsgSpec message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encodeDelimited(message: SysMsg.ISystemMessageMsgSpec, writer?: $protobuf.Writer): $protobuf.Writer;
/** /**
* Decodes a SystemMessageMsgSpec message from the specified reader or buffer. * Decodes a SystemMessageMsgSpec message from the specified reader or buffer.
* @param reader Reader or buffer to decode from * @param reader Reader or buffer to decode from
@@ -318,34 +193,6 @@ export namespace SysMsg {
*/ */
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.SystemMessageMsgSpec; public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.SystemMessageMsgSpec;
/**
* Verifies a SystemMessageMsgSpec message.
* @param message Plain object to verify
* @returns `null` if valid, otherwise the reason why it is not
*/
public static verify(message: { [k: string]: any }): (string|null);
/**
* Creates a SystemMessageMsgSpec message from a plain object. Also converts values to their respective internal types.
* @param object Plain object
* @returns SystemMessageMsgSpec
*/
public static fromObject(object: { [k: string]: any }): SysMsg.SystemMessageMsgSpec;
/**
* Creates a plain object from a SystemMessageMsgSpec message. Also converts values to other types if specified.
* @param message SystemMessageMsgSpec
* @param [options] Conversion options
* @returns Plain object
*/
public static toObject(message: SysMsg.SystemMessageMsgSpec, options?: $protobuf.IConversionOptions): { [k: string]: any };
/**
* Converts this SystemMessageMsgSpec to JSON.
* @returns JSON object
*/
public toJSON(): { [k: string]: any };
/** /**
* Gets the default type url for SystemMessageMsgSpec * Gets the default type url for SystemMessageMsgSpec
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
@@ -373,29 +220,6 @@ export namespace SysMsg {
/** SystemMessageBodyWrapper body. */ /** SystemMessageBodyWrapper body. */
public body: Uint8Array; 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;
/**
* Encodes the specified SystemMessageBodyWrapper message. Does not implicitly {@link SysMsg.SystemMessageBodyWrapper.verify|verify} messages.
* @param message SystemMessageBodyWrapper message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(message: SysMsg.ISystemMessageBodyWrapper, writer?: $protobuf.Writer): $protobuf.Writer;
/**
* Encodes the specified SystemMessageBodyWrapper message, length delimited. Does not implicitly {@link SysMsg.SystemMessageBodyWrapper.verify|verify} messages.
* @param message SystemMessageBodyWrapper message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encodeDelimited(message: SysMsg.ISystemMessageBodyWrapper, writer?: $protobuf.Writer): $protobuf.Writer;
/** /**
* Decodes a SystemMessageBodyWrapper message from the specified reader or buffer. * Decodes a SystemMessageBodyWrapper message from the specified reader or buffer.
* @param reader Reader or buffer to decode from * @param reader Reader or buffer to decode from
@@ -415,34 +239,6 @@ export namespace SysMsg {
*/ */
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.SystemMessageBodyWrapper; public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.SystemMessageBodyWrapper;
/**
* Verifies a SystemMessageBodyWrapper message.
* @param message Plain object to verify
* @returns `null` if valid, otherwise the reason why it is not
*/
public static verify(message: { [k: string]: any }): (string|null);
/**
* Creates a SystemMessageBodyWrapper message from a plain object. Also converts values to their respective internal types.
* @param object Plain object
* @returns SystemMessageBodyWrapper
*/
public static fromObject(object: { [k: string]: any }): SysMsg.SystemMessageBodyWrapper;
/**
* Creates a plain object from a SystemMessageBodyWrapper message. Also converts values to other types if specified.
* @param message SystemMessageBodyWrapper
* @param [options] Conversion options
* @returns Plain object
*/
public static toObject(message: SysMsg.SystemMessageBodyWrapper, options?: $protobuf.IConversionOptions): { [k: string]: any };
/**
* Converts this SystemMessageBodyWrapper to JSON.
* @returns JSON object
*/
public toJSON(): { [k: string]: any };
/** /**
* Gets the default type url for SystemMessageBodyWrapper * Gets the default type url for SystemMessageBodyWrapper
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
@@ -482,29 +278,6 @@ export namespace SysMsg {
/** LikeDetail nickname. */ /** LikeDetail nickname. */
public nickname: string; 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;
/**
* Encodes the specified LikeDetail message. Does not implicitly {@link SysMsg.LikeDetail.verify|verify} messages.
* @param message LikeDetail message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(message: SysMsg.ILikeDetail, writer?: $protobuf.Writer): $protobuf.Writer;
/**
* Encodes the specified LikeDetail message, length delimited. Does not implicitly {@link SysMsg.LikeDetail.verify|verify} messages.
* @param message LikeDetail message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encodeDelimited(message: SysMsg.ILikeDetail, writer?: $protobuf.Writer): $protobuf.Writer;
/** /**
* Decodes a LikeDetail message from the specified reader or buffer. * Decodes a LikeDetail message from the specified reader or buffer.
* @param reader Reader or buffer to decode from * @param reader Reader or buffer to decode from
@@ -524,34 +297,6 @@ export namespace SysMsg {
*/ */
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.LikeDetail; public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.LikeDetail;
/**
* Verifies a LikeDetail message.
* @param message Plain object to verify
* @returns `null` if valid, otherwise the reason why it is not
*/
public static verify(message: { [k: string]: any }): (string|null);
/**
* Creates a LikeDetail message from a plain object. Also converts values to their respective internal types.
* @param object Plain object
* @returns LikeDetail
*/
public static fromObject(object: { [k: string]: any }): SysMsg.LikeDetail;
/**
* Creates a plain object from a LikeDetail message. Also converts values to other types if specified.
* @param message LikeDetail
* @param [options] Conversion options
* @returns Plain object
*/
public static toObject(message: SysMsg.LikeDetail, options?: $protobuf.IConversionOptions): { [k: string]: any };
/**
* Converts this LikeDetail to JSON.
* @returns JSON object
*/
public toJSON(): { [k: string]: any };
/** /**
* Gets the default type url for LikeDetail * Gets the default type url for LikeDetail
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
@@ -591,29 +336,6 @@ export namespace SysMsg {
/** LikeMsg detail. */ /** LikeMsg detail. */
public detail?: (SysMsg.ILikeDetail|null); 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;
/**
* Encodes the specified LikeMsg message. Does not implicitly {@link SysMsg.LikeMsg.verify|verify} messages.
* @param message LikeMsg message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(message: SysMsg.ILikeMsg, writer?: $protobuf.Writer): $protobuf.Writer;
/**
* Encodes the specified LikeMsg message, length delimited. Does not implicitly {@link SysMsg.LikeMsg.verify|verify} messages.
* @param message LikeMsg message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encodeDelimited(message: SysMsg.ILikeMsg, writer?: $protobuf.Writer): $protobuf.Writer;
/** /**
* Decodes a LikeMsg message from the specified reader or buffer. * Decodes a LikeMsg message from the specified reader or buffer.
* @param reader Reader or buffer to decode from * @param reader Reader or buffer to decode from
@@ -633,34 +355,6 @@ export namespace SysMsg {
*/ */
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.LikeMsg; public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.LikeMsg;
/**
* Verifies a LikeMsg message.
* @param message Plain object to verify
* @returns `null` if valid, otherwise the reason why it is not
*/
public static verify(message: { [k: string]: any }): (string|null);
/**
* Creates a LikeMsg message from a plain object. Also converts values to their respective internal types.
* @param object Plain object
* @returns LikeMsg
*/
public static fromObject(object: { [k: string]: any }): SysMsg.LikeMsg;
/**
* Creates a plain object from a LikeMsg message. Also converts values to other types if specified.
* @param message LikeMsg
* @param [options] Conversion options
* @returns Plain object
*/
public static toObject(message: SysMsg.LikeMsg, options?: $protobuf.IConversionOptions): { [k: string]: any };
/**
* Converts this LikeMsg to JSON.
* @returns JSON object
*/
public toJSON(): { [k: string]: any };
/** /**
* Gets the default type url for LikeMsg * Gets the default type url for LikeMsg
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
@@ -688,29 +382,6 @@ export namespace SysMsg {
/** ProfileLikeTip msg. */ /** ProfileLikeTip msg. */
public msg?: (SysMsg.ILikeMsg|null); 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;
/**
* Encodes the specified ProfileLikeTip message. Does not implicitly {@link SysMsg.ProfileLikeTip.verify|verify} messages.
* @param message ProfileLikeTip message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(message: SysMsg.IProfileLikeTip, writer?: $protobuf.Writer): $protobuf.Writer;
/**
* Encodes the specified ProfileLikeTip message, length delimited. Does not implicitly {@link SysMsg.ProfileLikeTip.verify|verify} messages.
* @param message ProfileLikeTip message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encodeDelimited(message: SysMsg.IProfileLikeTip, writer?: $protobuf.Writer): $protobuf.Writer;
/** /**
* Decodes a ProfileLikeTip message from the specified reader or buffer. * Decodes a ProfileLikeTip message from the specified reader or buffer.
* @param reader Reader or buffer to decode from * @param reader Reader or buffer to decode from
@@ -730,34 +401,6 @@ export namespace SysMsg {
*/ */
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.ProfileLikeTip; public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.ProfileLikeTip;
/**
* Verifies a ProfileLikeTip message.
* @param message Plain object to verify
* @returns `null` if valid, otherwise the reason why it is not
*/
public static verify(message: { [k: string]: any }): (string|null);
/**
* Creates a ProfileLikeTip message from a plain object. Also converts values to their respective internal types.
* @param object Plain object
* @returns ProfileLikeTip
*/
public static fromObject(object: { [k: string]: any }): SysMsg.ProfileLikeTip;
/**
* Creates a plain object from a ProfileLikeTip message. Also converts values to other types if specified.
* @param message ProfileLikeTip
* @param [options] Conversion options
* @returns Plain object
*/
public static toObject(message: SysMsg.ProfileLikeTip, options?: $protobuf.IConversionOptions): { [k: string]: any };
/**
* Converts this ProfileLikeTip to JSON.
* @returns JSON object
*/
public toJSON(): { [k: string]: any };
/** /**
* Gets the default type url for ProfileLikeTip * Gets the default type url for ProfileLikeTip
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")

File diff suppressed because it is too large Load Diff

View File

@@ -282,9 +282,23 @@ export interface PicElement {
} }
export enum GrayTipElementSubType { export enum GrayTipElementSubType {
RECALL = 1, REVOKE = 1,
INVITE_NEW_MEMBER = 12, PROCLAMATION = 2,
MEMBER_NEW_TITLE = 17, 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 { export interface GrayTipElement {

View File

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

View File

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

View File

@@ -20,9 +20,9 @@ export class UploadGroupFile extends BaseAction<UploadGroupFilePayload, null> {
if (!success) { if (!success) {
throw new Error(errMsg) throw new Error(errMsg)
} }
const sendFileEle = await SendElementEntities.file(this.ctx, path, payload.name || fileName, payload.folder_id) const file = await SendElementEntities.file(this.ctx, path, payload.name || fileName, payload.folder ?? payload.folder_id)
const peer = await createPeer(this.ctx, payload, CreatePeerMode.Group) const peer = await createPeer(this.ctx, payload, CreatePeerMode.Group)
await sendMsg(this.ctx, peer, [sendFileEle], []) await sendMsg(this.ctx, peer, [file], [])
return null return null
} }
} }

View File

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

View File

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

View File

@@ -49,7 +49,8 @@ import { pathToFileURL } from 'node:url'
import OneBot11Adapter from './adapter' import OneBot11Adapter from './adapter'
export namespace OB11Entities { 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 { const {
debug, debug,
messagePostFormat, messagePostFormat,
@@ -57,14 +58,14 @@ export namespace OB11Entities {
const selfUin = selfInfo.uin const selfUin = selfInfo.uin
const resMsg: OB11Message = { const resMsg: OB11Message = {
self_id: parseInt(selfUin), self_id: parseInt(selfUin),
user_id: parseInt(msg.senderUin!), user_id: parseInt(msg.senderUin),
time: parseInt(msg.msgTime) || Date.now(), time: parseInt(msg.msgTime) || Date.now(),
message_id: msg.msgShortId!, message_id: msg.msgShortId!,
real_id: msg.msgShortId!, real_id: msg.msgShortId!,
message_seq: msg.msgShortId!, message_seq: msg.msgShortId!,
message_type: msg.chatType === ChatType.group ? 'group' : 'private', message_type: msg.chatType === ChatType.group ? 'group' : 'private',
sender: { sender: {
user_id: parseInt(msg.senderUin!), user_id: parseInt(msg.senderUin),
nickname: msg.sendNickName, nickname: msg.sendNickName,
card: msg.sendMemberName ?? '', card: msg.sendMemberName ?? '',
}, },
@@ -81,7 +82,7 @@ export namespace OB11Entities {
if (msg.chatType === ChatType.group) { if (msg.chatType === ChatType.group) {
resMsg.sub_type = 'normal' resMsg.sub_type = 'normal'
resMsg.group_id = parseInt(msg.peerUin) 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) { if (member) {
resMsg.sender.role = groupMemberRole(member.role) resMsg.sender.role = groupMemberRole(member.role)
resMsg.sender.nickname = member.nick resMsg.sender.nickname = member.nick
@@ -373,11 +374,10 @@ export namespace OB11Entities {
} }
for (const element of msg.elements) { for (const element of msg.elements) {
if (element.grayTipElement) { if (element.grayTipElement) {
if (element.grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE) { const { grayTipElement } = element
const json = JSON.parse(element.grayTipElement.jsonGrayTipElement.jsonStr) if (grayTipElement.subElementType === GrayTipElementSubType.JSON) {
if (element.grayTipElement.jsonGrayTipElement.busiId == 1061) { const json = JSON.parse(grayTipElement.jsonGrayTipElement.jsonStr)
//判断业务类型 if (grayTipElement.jsonGrayTipElement.busiId === 1061) {
//Poke事件
const pokedetail: Dict[] = json.items const pokedetail: Dict[] = json.items
//筛选item带有uid的元素 //筛选item带有uid的元素
const poke_uid = pokedetail.filter(item => item.uid) const poke_uid = pokedetail.filter(item => item.uid)
@@ -389,7 +389,6 @@ export namespace OB11Entities {
) )
} }
} }
//下面得改 上面也是错的grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE
} }
} }
} }
@@ -489,7 +488,7 @@ export namespace OB11Entities {
} }
} }
else if (element.fileElement) { else if (element.fileElement) {
return new OB11GroupUploadNoticeEvent(parseInt(msg.peerUid), parseInt(msg.senderUin!), { return new OB11GroupUploadNoticeEvent(+msg.peerUid, +msg.senderUin!, {
id: element.fileElement.fileUuid!, id: element.fileElement.fileUuid!,
name: element.fileElement.fileName, name: element.fileElement.fileName,
size: parseInt(element.fileElement.fileSize), size: parseInt(element.fileElement.fileSize),
@@ -543,7 +542,7 @@ export namespace OB11Entities {
} }
if ( if (
grayTipElement.subElementType == GrayTipElementSubType.INVITE_NEW_MEMBER && grayTipElement.subElementType == GrayTipElementSubType.XMLMSG &&
xmlElement?.templId == '10179' xmlElement?.templId == '10179'
) { ) {
ctx.logger.info('收到新人被邀请进群消息', grayTipElement) 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) 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) { if (grayTipElement.jsonGrayTipElement.busiId == 1061) {
//判断业务类型
//Poke事件
const pokedetail: Dict[] = json.items const pokedetail: Dict[] = json.items
//筛选item带有uid的元素 //筛选item带有uid的元素
const poke_uid = pokedetail.filter(item => item.uid) const poke_uid = pokedetail.filter(item => item.uid)
@@ -653,7 +626,7 @@ export namespace OB11Entities {
shortId: number shortId: number
): Promise<OB11FriendRecallNoticeEvent | OB11GroupRecallNoticeEvent | undefined> { ): Promise<OB11FriendRecallNoticeEvent | OB11GroupRecallNoticeEvent | undefined> {
const msgElement = msg.elements.find( const msgElement = msg.elements.find(
(element) => element.grayTipElement?.subElementType === GrayTipElementSubType.RECALL, (element) => element.grayTipElement?.subElementType === GrayTipElementSubType.REVOKE,
) )
if (!msgElement) { if (!msgElement) {
return return

View File

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