mirror of https://github.com/Nofated095/Q2TG.git
feat: add makeLongMsg function
This commit is contained in:
parent
48bca424ed
commit
b813fed54c
|
@ -26,7 +26,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/http-proxy": "^9.4.0",
|
"@fastify/http-proxy": "^9.4.0",
|
||||||
"@fastify/static": "^7.0.1",
|
"@fastify/static": "^7.0.1",
|
||||||
"@icqqjs/icqq": "^1.1.2",
|
"@icqqjs/icqq": "1.0.2",
|
||||||
"@prisma/client": "5.9.1",
|
"@prisma/client": "5.9.1",
|
||||||
"axios": "^1.6.8",
|
"axios": "^1.6.8",
|
||||||
"baidu-aip-sdk": "^4.16.15",
|
"baidu-aip-sdk": "^4.16.15",
|
||||||
|
|
|
@ -4,9 +4,9 @@ import {
|
||||||
Friend,
|
Friend,
|
||||||
Group,
|
Group,
|
||||||
GroupMessageEvent,
|
GroupMessageEvent,
|
||||||
LogLevel,
|
LogLevel, MessageElem,
|
||||||
Platform, PrivateMessage,
|
Platform, PrivateMessage,
|
||||||
PrivateMessageEvent,
|
PrivateMessageEvent, Sendable,
|
||||||
} from '@icqqjs/icqq';
|
} from '@icqqjs/icqq';
|
||||||
import random from '../utils/random';
|
import random from '../utils/random';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
@ -14,7 +14,7 @@ import fsP from 'fs/promises';
|
||||||
import { Config } from '@icqqjs/icqq/lib/client';
|
import { Config } from '@icqqjs/icqq/lib/client';
|
||||||
import dataPath from '../helpers/dataPath';
|
import dataPath from '../helpers/dataPath';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import { Converter, Image, rand2uuid } from '@icqqjs/icqq/lib/message';
|
import { Converter, Image, LongMsgElem, rand2uuid } from '@icqqjs/icqq/lib/message';
|
||||||
import { randomBytes } from 'crypto';
|
import { randomBytes } from 'crypto';
|
||||||
import { gzip, timestamp } from '@icqqjs/icqq/lib/common';
|
import { gzip, timestamp } from '@icqqjs/icqq/lib/common';
|
||||||
import { pb } from '@icqqjs/icqq/lib/core';
|
import { pb } from '@icqqjs/icqq/lib/core';
|
||||||
|
@ -229,4 +229,15 @@ export default class OicqClient extends Client {
|
||||||
resid,
|
resid,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async makeLongMsg(message: Sendable): Promise<LongMsgElem> {
|
||||||
|
const forward = await this.makeForwardMsgSelf({
|
||||||
|
message,
|
||||||
|
user_id: this.uin,
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
type: 'longmsg',
|
||||||
|
resId: forward.resid,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
},
|
},
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"patchedDependencies": {
|
"patchedDependencies": {
|
||||||
"@icqqjs/icqq@1.1.2": "patches/icqq@0.6.10.patch"
|
"@icqqjs/icqq@1.0.2": "patches/@icqqjs__icqq@1.0.2.patch"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
diff --git a/lib/message/converter.d.ts b/lib/message/converter.d.ts
|
||||||
|
index 72bb7f63a49d360b8954f1c196fb22973c2ae07c..870ac46e22d3cc00f53586872294b320ba943e10 100644
|
||||||
|
--- a/lib/message/converter.d.ts
|
||||||
|
+++ b/lib/message/converter.d.ts
|
||||||
|
@@ -54,6 +54,7 @@ export declare class Converter {
|
||||||
|
private mirai;
|
||||||
|
private file;
|
||||||
|
private reply;
|
||||||
|
+ private longmsg;
|
||||||
|
/** 转换为分片消息 */
|
||||||
|
toFragments(): Uint8Array[];
|
||||||
|
private _divideText;
|
||||||
|
diff --git a/lib/message/converter.js b/lib/message/converter.js
|
||||||
|
index c821bb3cdb5a404b1a7ef66883c3b22192b0c16d..bbf9687b48391968fab291c9dd59a05b84e21bac 100644
|
||||||
|
--- a/lib/message/converter.js
|
||||||
|
+++ b/lib/message/converter.js
|
||||||
|
@@ -92,7 +92,7 @@ class Converter {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (qq === "all") {
|
||||||
|
- var q = 0, flag = 1, display = "全体成员";
|
||||||
|
+ var q = 0, flag = 1, display = text || "全体成员";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var q = Number(qq), flag = 0, display = text || String(qq);
|
||||||
|
@@ -101,7 +101,6 @@ class Converter {
|
||||||
|
display = member?.card || member?.nickname || display;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- display = "@" + display;
|
||||||
|
if (dummy)
|
||||||
|
return this._text(display);
|
||||||
|
const buf = Buffer.allocUnsafe(6);
|
||||||
|
@@ -437,6 +436,15 @@ class Converter {
|
||||||
|
});
|
||||||
|
this.brief += data;
|
||||||
|
}
|
||||||
|
+ longmsg(elem) {
|
||||||
|
+ const { resId } = elem;
|
||||||
|
+ this.elems.push({
|
||||||
|
+ 37: {
|
||||||
|
+ 6: 1,
|
||||||
|
+ 7: resId
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
|
+ }
|
||||||
|
file(elem) {
|
||||||
|
throw new Error("暂不支持发送或转发file元素,请调用文件相关API完成该操作");
|
||||||
|
}
|
||||||
|
diff --git a/lib/message/elements.d.ts b/lib/message/elements.d.ts
|
||||||
|
index 3484802aeb6b9a26593dbc672284b30e42a6457e..3c606ea5e5650c3e60ea703ee2717f399d0e3601 100644
|
||||||
|
--- a/lib/message/elements.d.ts
|
||||||
|
+++ b/lib/message/elements.d.ts
|
||||||
|
@@ -182,6 +182,10 @@ export interface ButtonElem {
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
+export interface LongMsgElem {
|
||||||
|
+ type: "longmsg";
|
||||||
|
+ resId: string;
|
||||||
|
+}
|
||||||
|
export interface Button {
|
||||||
|
/** 按钮ID:在一个keyboard消息内设置唯一 */
|
||||||
|
id?: string;
|
||||||
|
@@ -288,7 +292,7 @@ export interface ForwardNode extends Forwardable {
|
||||||
|
export type ChainElem = TextElem | FaceElem | BfaceElem | MfaceElem | ImageElem | AtElem | MiraiElem | ReplyElem | ForwardNode | QuoteElem | MarkdownElem | ButtonElem;
|
||||||
|
export declare const ChainElemTypes: ChainElem["type"][];
|
||||||
|
/** 注意:只有`ChainElem`中的元素可以组合发送,其他元素只能单独发送 */
|
||||||
|
-export type MessageElem = TextElem | FaceElem | BfaceElem | MfaceElem | ImageElem | AtElem | MiraiElem | ReplyElem | FlashElem | PttElem | VideoElem | JsonElem | XmlElem | PokeElem | LocationElem | ShareElem | MusicElem | FileElem | ForwardNode | QuoteElem | MarkdownElem | ButtonElem;
|
||||||
|
+export type MessageElem = TextElem | FaceElem | BfaceElem | MfaceElem | ImageElem | AtElem | MiraiElem | ReplyElem | FlashElem | PttElem | VideoElem | JsonElem | XmlElem | PokeElem | LocationElem | ShareElem | MusicElem | FileElem | ForwardNode | QuoteElem | MarkdownElem | ButtonElem | LongMsgElem;
|
||||||
|
/** 可通过`sendMsg`发送的类型集合 (字符串、元素对象,或它们的数组) */
|
||||||
|
export type Sendable = string | MessageElem | (string | MessageElem)[];
|
||||||
|
/** 用于构造消息元素 */
|
||||||
|
@@ -321,6 +325,7 @@ export declare const segment: {
|
||||||
|
xml(data: string, id?: number): XmlElem;
|
||||||
|
markdown(content: string): MarkdownElem;
|
||||||
|
button(content: ButtonElem["content"]): ButtonElem;
|
||||||
|
+ longmsg(resId: string): LongMsgElem;
|
||||||
|
/** 一种特殊消息(官方客户端无法解析) */
|
||||||
|
mirai(data: string): MiraiElem;
|
||||||
|
/** 音乐 */
|
||||||
|
diff --git a/lib/message/elements.js b/lib/message/elements.js
|
||||||
|
index de3a1d116c794ae2ee9e18836d6669a4d89d59d0..9c6c5c1fc5949eb49636d539aed4ed140bb3ec0a 100644
|
||||||
|
--- a/lib/message/elements.js
|
||||||
|
+++ b/lib/message/elements.js
|
||||||
|
@@ -99,6 +99,11 @@ exports.segment = {
|
||||||
|
type: "button", content
|
||||||
|
};
|
||||||
|
},
|
||||||
|
+ longmsg(resId) {
|
||||||
|
+ return {
|
||||||
|
+ type: "longmsg", resId
|
||||||
|
+ };
|
||||||
|
+ },
|
||||||
|
/** 一种特殊消息(官方客户端无法解析) */
|
||||||
|
mirai(data) {
|
||||||
|
return {
|
|
@ -1,21 +0,0 @@
|
||||||
diff --git a/lib/message/converter.js b/lib/message/converter.js
|
|
||||||
index c821bb3cdb5a404b1a7ef66883c3b22192b0c16d..e97774395375138be6c4489142ea3db79ba66538 100644
|
|
||||||
--- a/lib/message/converter.js
|
|
||||||
+++ b/lib/message/converter.js
|
|
||||||
@@ -92,7 +92,7 @@ class Converter {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (qq === "all") {
|
|
||||||
- var q = 0, flag = 1, display = "全体成员";
|
|
||||||
+ var q = 0, flag = 1, display = text || "全体成员";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var q = Number(qq), flag = 0, display = text || String(qq);
|
|
||||||
@@ -101,7 +101,6 @@ class Converter {
|
|
||||||
display = member?.card || member?.nickname || display;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- display = "@" + display;
|
|
||||||
if (dummy)
|
|
||||||
return this._text(display);
|
|
||||||
const buf = Buffer.allocUnsafe(6);
|
|
|
@ -5,9 +5,9 @@ settings:
|
||||||
excludeLinksFromLockfile: false
|
excludeLinksFromLockfile: false
|
||||||
|
|
||||||
patchedDependencies:
|
patchedDependencies:
|
||||||
'@icqqjs/icqq@1.1.2':
|
'@icqqjs/icqq@1.0.2':
|
||||||
hash: lvxibeykgrherv3ldsrdfzrnaq
|
hash: wxe3a6ue6lwbvkaznekqvakwcq
|
||||||
path: patches/icqq@0.6.10.patch
|
path: patches/@icqqjs__icqq@1.0.2.patch
|
||||||
|
|
||||||
importers:
|
importers:
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ importers:
|
||||||
specifier: ^7.0.1
|
specifier: ^7.0.1
|
||||||
version: 7.0.1
|
version: 7.0.1
|
||||||
'@icqqjs/icqq':
|
'@icqqjs/icqq':
|
||||||
specifier: ^1.1.2
|
specifier: 1.0.2
|
||||||
version: 1.1.2(patch_hash=lvxibeykgrherv3ldsrdfzrnaq)
|
version: 1.0.2(patch_hash=wxe3a6ue6lwbvkaznekqvakwcq)
|
||||||
'@prisma/client':
|
'@prisma/client':
|
||||||
specifier: 5.9.1
|
specifier: 5.9.1
|
||||||
version: 5.9.1(prisma@5.9.1)
|
version: 5.9.1(prisma@5.9.1)
|
||||||
|
@ -96,7 +96,7 @@ importers:
|
||||||
version: 0.2.2
|
version: 0.2.2
|
||||||
telegram:
|
telegram:
|
||||||
specifier: https://github.com/clansty/gramjs/releases/download/2.19.10%2Brevert_media/telegram-2.19.10.tgz
|
specifier: https://github.com/clansty/gramjs/releases/download/2.19.10%2Brevert_media/telegram-2.19.10.tgz
|
||||||
version: '@github.com/clansty/gramjs/releases/download/2.19.10%2525252525252Brevert_media/telegram-2.19.10.tgz'
|
version: '@github.com/clansty/gramjs/releases/download/2.19.10%2525252525252525252Brevert_media/telegram-2.19.10.tgz'
|
||||||
tmp-promise:
|
tmp-promise:
|
||||||
specifier: ^3.0.3
|
specifier: ^3.0.3
|
||||||
version: 3.0.3
|
version: 3.0.3
|
||||||
|
@ -786,14 +786,14 @@ packages:
|
||||||
glob: 10.3.10
|
glob: 10.3.10
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@icqqjs/icqq@1.1.2(patch_hash=lvxibeykgrherv3ldsrdfzrnaq):
|
/@icqqjs/icqq@1.0.2(patch_hash=wxe3a6ue6lwbvkaznekqvakwcq):
|
||||||
resolution: {integrity: sha512-5hvFVYlV6qp7leC60c+HGfgjhK5udSIN92mEUfzbWKK+Xx8Z2ruMEAzIzfOcFkBugyzmjX5vxhymDH3diQm0pA==, tarball: https://npm.pkg.github.com/download/@icqqjs/icqq/1.1.2/aa71ad688f4e2ca32f883cef340f2387968d12c6}
|
resolution: {integrity: sha512-SThmVjnSMpDNjtiCChjOLHsl8hUnWxrdMYLADGL1DxG+dUu5qgVJY7/bVI15MnC16FGz+moksl50A+cMyTSJww==, tarball: https://npm.pkg.github.com/download/@icqqjs/icqq/1.0.2/e21d5e48c12b466908cdf298283b6e4a2d532d2d}
|
||||||
engines: {node: '>= v14'}
|
engines: {node: '>= v14'}
|
||||||
dependencies:
|
dependencies:
|
||||||
axios: 1.6.8
|
axios: 1.6.8
|
||||||
log4js: 6.9.1
|
log4js: 6.9.1
|
||||||
long: 5.2.3
|
long: 4.0.0
|
||||||
pngjs: 7.0.0
|
pngjs: 6.0.0
|
||||||
probe-image-size: 7.2.3
|
probe-image-size: 7.2.3
|
||||||
silk-wasm: 3.2.3
|
silk-wasm: 3.2.3
|
||||||
triptrap: 0.0.17
|
triptrap: 0.0.17
|
||||||
|
@ -3797,8 +3797,8 @@ packages:
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/long@5.2.3:
|
/long@4.0.0:
|
||||||
resolution: {integrity: sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==}
|
resolution: {integrity: sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/lottie-node@2.0.0(canvas@2.11.2)(jsdom@16.7.0)(lottie-web@5.12.2):
|
/lottie-node@2.0.0(canvas@2.11.2)(jsdom@16.7.0)(lottie-web@5.12.2):
|
||||||
|
@ -4306,11 +4306,6 @@ packages:
|
||||||
engines: {node: '>=12.13.0'}
|
engines: {node: '>=12.13.0'}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/pngjs@7.0.0:
|
|
||||||
resolution: {integrity: sha512-LKWqWJRhstyYo9pGvgor/ivk2w94eSjE3RGVuzLGlr3NmD8bf7RcYGze1mNdEHRP6TRP6rMuDHk5t44hnTRyow==}
|
|
||||||
engines: {node: '>=14.19.0'}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/postcss@8.4.35:
|
/postcss@8.4.35:
|
||||||
resolution: {integrity: sha512-u5U8qYpBCpN13BsiEB0CbR1Hhh4Gc0zLFuedrHJKMctHCHAGrMdG0PRM/KErzAL3CU6/eckEtmHNB3x6e3c0vA==}
|
resolution: {integrity: sha512-u5U8qYpBCpN13BsiEB0CbR1Hhh4Gc0zLFuedrHJKMctHCHAGrMdG0PRM/KErzAL3CU6/eckEtmHNB3x6e3c0vA==}
|
||||||
engines: {node: ^10 || ^12 || >=14}
|
engines: {node: ^10 || ^12 || >=14}
|
||||||
|
@ -5673,7 +5668,7 @@ packages:
|
||||||
- utf-8-validate
|
- utf-8-validate
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
'@github.com/clansty/gramjs/releases/download/2.19.10%2525252525252Brevert_media/telegram-2.19.10.tgz':
|
'@github.com/clansty/gramjs/releases/download/2.19.10%2525252525252525252Brevert_media/telegram-2.19.10.tgz':
|
||||||
resolution: {tarball: https://github.com/clansty/gramjs/releases/download/2.19.10%2Brevert_media/telegram-2.19.10.tgz}
|
resolution: {tarball: https://github.com/clansty/gramjs/releases/download/2.19.10%2Brevert_media/telegram-2.19.10.tgz}
|
||||||
name: telegram
|
name: telegram
|
||||||
version: 2.19.10
|
version: 2.19.10
|
||||||
|
|
Loading…
Reference in New Issue