koishi-plugin-node-async-bot-all 2.25.0 → 2.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands.d.ts +1 -0
- package/lib/fun.d.ts +1 -1
- package/lib/index.js +21 -6
- package/package.json +1 -1
- package/res/userMsg.html +43 -3
package/lib/commands.d.ts
CHANGED
package/lib/fun.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare function getMsgCount(ctx: Context): Promise<Object>;
|
|
|
37
37
|
export declare function random(type: number | undefined, data: any, data2?: any): number;
|
|
38
38
|
export declare function request<T = any>(url: string, options?: RequestInit, timeout?: number, log?: any): Promise<HttpResponse<T>>;
|
|
39
39
|
export declare function readUserCardFile(userInfo: APIUserInfo): Promise<string>;
|
|
40
|
-
export declare function readUserMsgFile(userName: string, userAvatar: string, msg: string, inversion: boolean | undefined): Promise<string>;
|
|
40
|
+
export declare function readUserMsgFile(userName: string, userAvatar: string, msg: string, inversion: boolean | undefined, replyUserName: string | undefined, replyMsg: string | undefined): Promise<string>;
|
|
41
41
|
export declare function queryA2S(host: string, log: any): Promise<serverInfo>;
|
|
42
42
|
export declare function readNewsFile(info: APINews, log: any): Promise<string[]>;
|
|
43
43
|
export declare function translateAPI(log: any, text: string): Promise<string>;
|
package/lib/index.js
CHANGED
|
@@ -34,7 +34,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
34
34
|
// src/locales/zh-CN.yml
|
|
35
35
|
var require_zh_CN = __commonJS({
|
|
36
36
|
"src/locales/zh-CN.yml"(exports2, module2) {
|
|
37
|
-
module2.exports = { noApi: "未指定 API", noop: "无", unknownError: "未知错误。", commands: { na: { description: "NodeAsync Bot" }, cxgame: { description: "查询服务器当前人数。", messages: { msg: "{time}{list}\n进服指南请在群公告中查看。", list: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 玩家列表:{list}\n➣ 备注:{note}", listNoPlayer: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 备注:{note}", listFailed: "【MC 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。\n➣ 备注:{note}", listA2S: "【A2S 服务器 {count}】\n➣ {version}:{players}\n➣ 机器人:{bots}\n➣ 备注:{note}", listFailedA2S: "【A2S 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。\n➣ 备注:{note}", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}", timeout: "请求超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", host: "没有到主机的路由。", dns: "解析失败。" } }, status: { description: "查询机器人状态。", messages: { msg: "{time}\n--- 系统状态 ---\n系统名称:{name}\nCPU使用率:{cpu}\n内存使用率:{memory}\n--- 机器人状态 ---\n昨日收/发消息数量:{msgCount}\n机器人版本:{version}\n运行时间:{online}", failed: "{time}\n状态获取失败。" } }, random: { description: "随机数生成器。", usage: "缺少参数时默认生成 0-10000 的随机数。\n使用示例:", examples: "random 1 128 生成1到128范围的随机数", messages: { msg: "{time}\n生成的随机数:{data}" } }, info: { description: "查询机器人信息。", messages: { msg: "{data}", failed: "{time}\n读取信息失败。" } }, rw: { description: "随机名言名句。", messages: { msg: "{time}\n{data}", failed: "{time}\n获取失败({data})。" } }, randomba: { description: "随机BA图。", messages: { msg: "{quote}{image}", wait: "{quote}{time}\n请等待图片上传(可能较慢)。" } }, centerservertest: { description: "查看中心服务器状态。", messages: { msg: "{time}{list}", list: "== {name} ==\n状态:{status}\n存活率:{uptime}\n检测时间:{time}", listFailed: "== {name} ==\n查看失败:{data}", failed: "{time}\n查看失败:{data}", statusLive: "✅ 正常", statusDie: "❌ 故障", dataFail: "未能获取到此服务器的状态信息。" } }, meme: { description: "群友的怪话!", usage: "不带参数时随机查看\n带参数时为查看指定 meme", examples: "meme\nmeme 1145", messages: { msg: "{quote}{time}\n{image}\n{title}", failed: "{quote}{time}\n获取失败:{data}", forbidden: "{quote}{time}\n此指令不允许在本群使用。" } }, randomcat: { description: "随机猫猫图。", messages: { msg: "{quote}{image}", wait: "{quote}{time}\n请等待图片上传(可能较慢)。", failed: "{quote}{time}\n获取失败:{data}" } }, getqqinfo: { description: "获取 QQ 号的信息。", usage: "获取 QQ 号的信息。", examples: "getqqinfo 10001", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", command: "QQ 号不正确。" } }, msg2img: { description: "引用一个消息并使用此指令,即可将消息转图。", usage: "引用一条消息,/m。(不要带@)", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", null: "未引用任何消息。", matroska: "{quote}禁止套娃!" } }, slnews: { description: "抓取 NorthWood 的 Steam 最新新闻。" } } };
|
|
37
|
+
module2.exports = { noApi: "未指定 API", noop: "无", unknownError: "未知错误。", commands: { na: { description: "NodeAsync Bot" }, cxgame: { description: "查询服务器当前人数。", messages: { msg: "{time}{list}\n进服指南请在群公告中查看。", list: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 玩家列表:{list}\n➣ 备注:{note}", listNoPlayer: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 备注:{note}", listFailed: "【MC 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。\n➣ 备注:{note}", listA2S: "【A2S 服务器 {count}】\n➣ {version}:{players}\n➣ 机器人:{bots}\n➣ 备注:{note}", listFailedA2S: "【A2S 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。\n➣ 备注:{note}", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}", timeout: "请求超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", host: "没有到主机的路由。", dns: "解析失败。" } }, status: { description: "查询机器人状态。", messages: { msg: "{time}\n--- 系统状态 ---\n系统名称:{name}\nCPU使用率:{cpu}\n内存使用率:{memory}\n--- 机器人状态 ---\n昨日收/发消息数量:{msgCount}\n机器人版本:{version}\n运行时间:{online}", failed: "{time}\n状态获取失败。" } }, random: { description: "随机数生成器。", usage: "缺少参数时默认生成 0-10000 的随机数。\n使用示例:", examples: "random 1 128 生成1到128范围的随机数", messages: { msg: "{time}\n生成的随机数:{data}" } }, info: { description: "查询机器人信息。", messages: { msg: "{data}", failed: "{time}\n读取信息失败。" } }, rw: { description: "随机名言名句。", messages: { msg: "{time}\n{data}", failed: "{time}\n获取失败({data})。" } }, randomba: { description: "随机BA图。", messages: { msg: "{quote}{image}", wait: "{quote}{time}\n请等待图片上传(可能较慢)。" } }, centerservertest: { description: "查看中心服务器状态。", messages: { msg: "{time}{list}", list: "== {name} ==\n状态:{status}\n存活率:{uptime}\n检测时间:{time}", listFailed: "== {name} ==\n查看失败:{data}", failed: "{time}\n查看失败:{data}", statusLive: "✅ 正常", statusDie: "❌ 故障", dataFail: "未能获取到此服务器的状态信息。" } }, meme: { description: "群友的怪话!", usage: "不带参数时随机查看\n带参数时为查看指定 meme", examples: "meme\nmeme 1145", messages: { msg: "{quote}{time}\n{image}\n{title}", failed: "{quote}{time}\n获取失败:{data}", forbidden: "{quote}{time}\n此指令不允许在本群使用。" } }, randomcat: { description: "随机猫猫图。", messages: { msg: "{quote}{image}", wait: "{quote}{time}\n请等待图片上传(可能较慢)。", failed: "{quote}{time}\n获取失败:{data}" } }, getqqinfo: { description: "获取 QQ 号的信息。", usage: "获取 QQ 号的信息。", examples: "getqqinfo 10001", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", command: "QQ 号不正确。" } }, msg2img: { description: "引用一个消息并使用此指令,即可将消息转图。", usage: "引用一条消息,/m。(不要带@)", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", null: "未引用任何消息。", matroska: "{quote}禁止套娃!" } }, slnews: { description: "抓取 NorthWood 的 Steam 最新新闻。" }, use: { description: "使用 TA !", usage: "use @用户", examples: "use @用户", messages: { command: "请 @ 一个用户。", msg: "{at} {desc}了 {at2} !" } } } };
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
|
|
@@ -253,19 +253,20 @@ async function readUserCardFile(userInfo) {
|
|
|
253
253
|
return card;
|
|
254
254
|
}
|
|
255
255
|
__name(readUserCardFile, "readUserCardFile");
|
|
256
|
-
async function readUserMsgFile(userName, userAvatar, msg, inversion) {
|
|
256
|
+
async function readUserMsgFile(userName, userAvatar, msg, inversion, replyUserName, replyMsg) {
|
|
257
257
|
let html;
|
|
258
258
|
try {
|
|
259
259
|
const aPath = import_path.default.resolve(__dirname, "..") + import_path.default.sep + "res" + import_path.default.sep + "userMsg.html";
|
|
260
260
|
html = await import_fs.default.promises.readFile(aPath, "utf8");
|
|
261
|
-
html = html.toString().replace("{userData.avatarUrl}", userAvatar).replace("{userData.username}", userName).replace("{userData.message}", msg).replace(
|
|
261
|
+
html = html.toString().replace("{userData.avatarUrl}", userAvatar).replace("{userData.username}", userName).replace("{userData.message}", msg).replace("{replyData.username}", replyUserName).replace("{replyData.message}", replyMsg).replace(
|
|
262
262
|
/<at\s+(?:id=["']([^"']*)["']\s+name=["']([^"']*)["']|name=["']([^"']*)["']\s+id=["']([^"']*)["'])\s*\/?>/g,
|
|
263
263
|
(match, id1, name1, name2, id2) => {
|
|
264
264
|
const name3 = name1 || name2 || id1 || id2 || match;
|
|
265
265
|
return `@${name3}`;
|
|
266
266
|
}
|
|
267
|
-
);
|
|
267
|
+
).replace('<at type="all"/>', "@全体成员");
|
|
268
268
|
if (inversion) html = html.replace("//// ", "");
|
|
269
|
+
if (replyUserName != void 0) html = html.replace("/**/ ", "//// ");
|
|
269
270
|
} catch (error) {
|
|
270
271
|
html = error.message;
|
|
271
272
|
}
|
|
@@ -829,6 +830,8 @@ async function getMsg(ctx, session, inversion) {
|
|
|
829
830
|
}
|
|
830
831
|
const user = await session.bot.getUser(session.quote.user.id, session.channelId);
|
|
831
832
|
const msg = session.quote.content;
|
|
833
|
+
const quoteMsg = session.quote.quote?.content;
|
|
834
|
+
const quoteUser = session.quote.quote?.user?.name;
|
|
832
835
|
log.debug(msg);
|
|
833
836
|
if (!user.name || !user.avatar) {
|
|
834
837
|
await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "time": time, "data": "获取用户信息失败。" }));
|
|
@@ -836,7 +839,7 @@ async function getMsg(ctx, session, inversion) {
|
|
|
836
839
|
return 1;
|
|
837
840
|
}
|
|
838
841
|
const page = await ctx.puppeteer.page();
|
|
839
|
-
const html = await readUserMsgFile(user.name, user.avatar, msg, inversion);
|
|
842
|
+
const html = await readUserMsgFile(user.name, user.avatar, msg, inversion, quoteUser, quoteMsg);
|
|
840
843
|
log.debug(html);
|
|
841
844
|
try {
|
|
842
845
|
await page.setViewport({
|
|
@@ -928,9 +931,16 @@ async function getNewsMsg(ctx, type) {
|
|
|
928
931
|
}
|
|
929
932
|
}
|
|
930
933
|
__name(getNewsMsg, "getNewsMsg");
|
|
934
|
+
async function getUse(ctx, session, qq, desc) {
|
|
935
|
+
const log = ctx.logger("getUse");
|
|
936
|
+
log.debug(`Got: {"form":"${session.platform}:${session.event.guild?.id}","user":"${session.event.user?.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message?.id}"}`);
|
|
937
|
+
await session.send(session.text(".msg", { "at": import_koishi2.h.at(session.event.user?.id), "at2": import_koishi2.h.at(qq), "desc": import_koishi2.h.text(desc.replace('<at type="all"/>', "")) ?? "使用" }));
|
|
938
|
+
return 0;
|
|
939
|
+
}
|
|
940
|
+
__name(getUse, "getUse");
|
|
931
941
|
|
|
932
942
|
// package.json
|
|
933
|
-
var version = "2.
|
|
943
|
+
var version = "2.26.1";
|
|
934
944
|
|
|
935
945
|
// src/index.ts
|
|
936
946
|
var inject = ["database", "installer", "puppeteer", "cron"];
|
|
@@ -1083,6 +1093,11 @@ ${import_koishi3.h.image(outMsg.data, "image/png")}`);
|
|
|
1083
1093
|
na.subcommand("msg2img").option("inversion", "-i").alias("消息转图").alias("m").action(async ({ session, options }) => {
|
|
1084
1094
|
await getMsg(ctx, session, options?.inversion);
|
|
1085
1095
|
});
|
|
1096
|
+
na.subcommand("use <user:user> [方法:string]").alias("u").action(async ({ session }, user, desc) => {
|
|
1097
|
+
const qq = user?.split(":")?.[1];
|
|
1098
|
+
if (qq == void 0 || isNaN(Number(qq))) return session?.text(".command");
|
|
1099
|
+
await getUse(ctx, session, qq, desc);
|
|
1100
|
+
});
|
|
1086
1101
|
}
|
|
1087
1102
|
__name(apply, "apply");
|
|
1088
1103
|
// Annotate the CommonJS export names for ESM import in node:
|
package/package.json
CHANGED
package/res/userMsg.html
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
background: #ffffff;
|
|
23
23
|
padding: 15px;
|
|
24
24
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
25
|
+
border-radius: 8px; /* 给卡片加一点圆角更好看 */
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
/* 头像样式 */
|
|
@@ -35,20 +36,51 @@
|
|
|
35
36
|
border: 1px solid #eee;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
/*
|
|
39
|
+
/* 消息气泡及内容容器 */
|
|
39
40
|
.content {
|
|
40
41
|
flex: 1;
|
|
41
42
|
display: flex;
|
|
42
43
|
flex-direction: column;
|
|
44
|
+
min-width: 0; /* 防止长文本撑破flex容器 */
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
.user-name {
|
|
46
48
|
font-weight: bold;
|
|
47
49
|
font-size: 14px;
|
|
48
50
|
color: #333;
|
|
49
|
-
margin-bottom:
|
|
51
|
+
margin-bottom: 6px;
|
|
50
52
|
}
|
|
51
53
|
|
|
54
|
+
/* ================= 新增:回复块样式 ================= */
|
|
55
|
+
.reply-block {
|
|
56
|
+
background: #f7f8fa;
|
|
57
|
+
border-left: 3px solid #b9bbbe; /* 引用线标记 */
|
|
58
|
+
padding: 6px 10px;
|
|
59
|
+
border-radius: 0 4px 4px 0;
|
|
60
|
+
margin-bottom: 8px;
|
|
61
|
+
/**/display:none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.reply-user {
|
|
65
|
+
font-size: 12px;
|
|
66
|
+
font-weight: 600;
|
|
67
|
+
color: #555;
|
|
68
|
+
margin-bottom: 3px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.reply-text {
|
|
72
|
+
font-size: 13px;
|
|
73
|
+
color: #777;
|
|
74
|
+
/* 长文本截断:最多显示2行 */
|
|
75
|
+
display: -webkit-box;
|
|
76
|
+
-webkit-line-clamp: 2;
|
|
77
|
+
-webkit-box-orient: vertical;
|
|
78
|
+
overflow: hidden;
|
|
79
|
+
text-overflow: ellipsis;
|
|
80
|
+
word-break: break-all;
|
|
81
|
+
}
|
|
82
|
+
/* =================================================== */
|
|
83
|
+
|
|
52
84
|
.text-bubble {
|
|
53
85
|
font-size: 15px;
|
|
54
86
|
line-height: 1.5;
|
|
@@ -61,14 +93,22 @@
|
|
|
61
93
|
word-wrap: break-word; /* 长单词断行 */
|
|
62
94
|
overflow-wrap: break-word;
|
|
63
95
|
word-break: break-all;
|
|
96
|
+
width: fit-content; /* 让气泡宽度适应内容 */
|
|
64
97
|
}
|
|
65
98
|
</style>
|
|
66
99
|
</head>
|
|
67
100
|
<body>
|
|
68
101
|
<div id="target-element" class="message-card">
|
|
69
|
-
<img src="{userData.avatarUrl}" class="avatar" />
|
|
102
|
+
<img src="{userData.avatarUrl}" class="avatar" alt="Avatar" />
|
|
70
103
|
<div class="content">
|
|
71
104
|
<div class="user-name">{userData.username}</div>
|
|
105
|
+
|
|
106
|
+
<!-- 新增的回复块 -->
|
|
107
|
+
<div class="reply-block">
|
|
108
|
+
<div class="reply-user">@{replyData.username}</div>
|
|
109
|
+
<div class="reply-text">{replyData.message}</div>
|
|
110
|
+
</div>
|
|
111
|
+
|
|
72
112
|
<div class="text-bubble">{userData.message}</div>
|
|
73
113
|
</div>
|
|
74
114
|
</div>
|