koishi-plugin-node-async-bot-all 2.20.0 → 2.20.2
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/index.js +14 -5
- package/package.json +1 -1
- package/res/userMsg.html +36 -42
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 = { commands: { 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➣ 请稍后重试。", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}", timeout: "请求超时。", timeout2: "响应超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", error: "执行错误。", host: "没有到主机的路由。" } }, 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}", error: "执行错误。", failed: "{time}\n获取失败({data})。" } }, randomba: { description: "随机BA图。", messages: { msg: "{quote}{image}", wait: "{quote}{time}\n请等待图片上传(可能较慢)。" } }, servertest: { description: "Ping服务器。", messages: { msg: "{time}\n== Ping {host} ==\n状态:{alive}\n丢包率:{packetLoss}\n返回IP:{ip}", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\nPing 失败:{data}" } }, meme: { description: "群友的怪话!", messages: { msg: "{quote}{time}\n{image}\n{title}", failed: "{quote}{time}\n获取失败:{data}", forbidden: "{quote}{time}\n此指令不允许在本群使用。", error: "执行错误。" } }, randomcat: { description: "随机猫猫图。", messages: { msg: "{quote}{image}", wait: "{quote}{time}\n请等待图片上传(可能较慢)。", failed: "{quote}{time}\n获取失败:{data}" } }, getqqinfo: { description: "获取 QQ 号的信息。", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", command: "QQ 号不正确。" } }, msg2img: { description: "引用一个消息并使用此指令,即可将消息转图。", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", null: "未引用任何消息。" } } } };
|
|
37
|
+
module2.exports = { commands: { 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➣ 请稍后重试。", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}", timeout: "请求超时。", timeout2: "响应超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", error: "执行错误。", host: "没有到主机的路由。" } }, 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}", error: "执行错误。", failed: "{time}\n获取失败({data})。" } }, randomba: { description: "随机BA图。", messages: { msg: "{quote}{image}", wait: "{quote}{time}\n请等待图片上传(可能较慢)。" } }, servertest: { description: "Ping服务器。", messages: { msg: "{time}\n== Ping {host} ==\n状态:{alive}\n丢包率:{packetLoss}\n返回IP:{ip}", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\nPing 失败:{data}" } }, meme: { description: "群友的怪话!", messages: { msg: "{quote}{time}\n{image}\n{title}", failed: "{quote}{time}\n获取失败:{data}", forbidden: "{quote}{time}\n此指令不允许在本群使用。", error: "执行错误。" } }, randomcat: { description: "随机猫猫图。", messages: { msg: "{quote}{image}", wait: "{quote}{time}\n请等待图片上传(可能较慢)。", failed: "{quote}{time}\n获取失败:{data}" } }, getqqinfo: { description: "获取 QQ 号的信息。", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", command: "QQ 号不正确。" } }, msg2img: { description: "引用一个消息并使用此指令,即可将消息转图。", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", null: "未引用任何消息。", matroska: "{quote}禁止套娃!" } } } };
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
|
|
@@ -475,7 +475,7 @@ async function getRandomWord(ctx, session) {
|
|
|
475
475
|
if (response.success) {
|
|
476
476
|
msg = {
|
|
477
477
|
"time": time,
|
|
478
|
-
"data": response.data,
|
|
478
|
+
"data": response.data.data,
|
|
479
479
|
"success": 0
|
|
480
480
|
};
|
|
481
481
|
log.debug("Sent:");
|
|
@@ -691,6 +691,10 @@ async function getMsg(ctx, session) {
|
|
|
691
691
|
log.warn("未引用任何信息");
|
|
692
692
|
return 1;
|
|
693
693
|
}
|
|
694
|
+
if (session.quote.user.id == session.event.selfId) {
|
|
695
|
+
await session.send(session.text(".matroska", { "quote": import_koishi2.h.quote(session.messageId) }));
|
|
696
|
+
return 1;
|
|
697
|
+
}
|
|
694
698
|
const user = await session.bot.getUser(session.quote.user.id, session.channelId);
|
|
695
699
|
const msg = session.quote.content;
|
|
696
700
|
if (!user.name || !user.avatar) {
|
|
@@ -702,11 +706,16 @@ async function getMsg(ctx, session) {
|
|
|
702
706
|
const html = await readUserMsgFile(user.name, user.avatar, msg);
|
|
703
707
|
try {
|
|
704
708
|
await page.setViewport({
|
|
705
|
-
width:
|
|
706
|
-
height:
|
|
709
|
+
width: 450,
|
|
710
|
+
height: 1,
|
|
707
711
|
deviceScaleFactor: 2
|
|
708
712
|
});
|
|
709
713
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
714
|
+
const { width, height } = await page.evaluate(() => ({
|
|
715
|
+
width: document.body.scrollWidth + 50,
|
|
716
|
+
height: document.body.scrollHeight
|
|
717
|
+
}));
|
|
718
|
+
await page.setViewport({ width, height, deviceScaleFactor: 2 });
|
|
710
719
|
const element = await page.$("#target-element");
|
|
711
720
|
if (element) {
|
|
712
721
|
const image = await element.screenshot({
|
|
@@ -733,7 +742,7 @@ async function getMsg(ctx, session) {
|
|
|
733
742
|
__name(getMsg, "getMsg");
|
|
734
743
|
|
|
735
744
|
// package.json
|
|
736
|
-
var version = "2.20.
|
|
745
|
+
var version = "2.20.2";
|
|
737
746
|
|
|
738
747
|
// src/index.ts
|
|
739
748
|
var inject = ["database", "installer", "puppeteer"];
|
package/package.json
CHANGED
package/res/userMsg.html
CHANGED
|
@@ -1,80 +1,74 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
|
-
<html
|
|
2
|
+
<html>
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
5
|
<title>UserMsg</title>
|
|
7
6
|
<style>
|
|
8
7
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
8
|
+
|
|
9
9
|
body {
|
|
10
10
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
11
|
-
background
|
|
12
|
-
padding: 20px;
|
|
13
|
-
display: flex;
|
|
14
|
-
justify-content: flex-start;
|
|
11
|
+
background: transparent;
|
|
12
|
+
padding: 20px; /* 给截图留一点边缘留白 */
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
/*
|
|
18
|
-
.
|
|
15
|
+
/* 核心容器 */
|
|
16
|
+
.message-card {
|
|
19
17
|
display: flex;
|
|
20
18
|
flex-direction: row;
|
|
21
19
|
align-items: flex-start;
|
|
22
|
-
|
|
23
|
-
background: #
|
|
24
|
-
padding:
|
|
25
|
-
|
|
26
|
-
/* 如果你想让图片就是气泡本身,可以去掉上面的 background 和 padding,保留下面的布局 */
|
|
20
|
+
width: 100%;
|
|
21
|
+
background: #ffffff;
|
|
22
|
+
padding: 15px;
|
|
23
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
27
24
|
}
|
|
28
25
|
|
|
29
|
-
/*
|
|
26
|
+
/* 头像样式 */
|
|
30
27
|
.avatar {
|
|
31
28
|
width: 50px;
|
|
32
29
|
height: 50px;
|
|
33
30
|
border-radius: 50%;
|
|
34
|
-
background-color: #ddd;
|
|
35
31
|
object-fit: cover;
|
|
36
|
-
flex-shrink: 0; /*
|
|
37
|
-
margin-right:
|
|
38
|
-
|
|
32
|
+
flex-shrink: 0; /* 防止被长文本挤压变形 */
|
|
33
|
+
margin-right: 15px;
|
|
34
|
+
border: 1px solid #eee;
|
|
39
35
|
}
|
|
40
36
|
|
|
41
|
-
/*
|
|
42
|
-
.content
|
|
37
|
+
/* 消息气泡样式 */
|
|
38
|
+
.content {
|
|
39
|
+
flex: 1;
|
|
43
40
|
display: flex;
|
|
44
41
|
flex-direction: column;
|
|
45
42
|
}
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
.user-name {
|
|
45
|
+
font-weight: bold;
|
|
49
46
|
font-size: 14px;
|
|
50
|
-
color: #
|
|
47
|
+
color: #333;
|
|
51
48
|
margin-bottom: 4px;
|
|
52
|
-
font-weight: 500;
|
|
53
49
|
}
|
|
54
50
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
background-color: #fff;
|
|
58
|
-
color: #333;
|
|
59
|
-
padding: 10px 14px;
|
|
60
|
-
border-radius: 0 12px 12px 12px; /* 左上角直角,其余圆角 */
|
|
61
|
-
font-size: 16px;
|
|
51
|
+
.text-bubble {
|
|
52
|
+
font-size: 15px;
|
|
62
53
|
line-height: 1.5;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
54
|
+
color: #444;
|
|
55
|
+
background: #f2f3f5;
|
|
56
|
+
padding: 10px 14px;
|
|
57
|
+
border-radius: 0 12px 12px 12px; /* 类似聊天气泡的圆角 */
|
|
58
|
+
|
|
59
|
+
white-space: pre-wrap; /* 保留换行符 */
|
|
60
|
+
word-wrap: break-word; /* 长单词断行 */
|
|
61
|
+
overflow-wrap: break-word;
|
|
62
|
+
word-break: break-all;
|
|
66
63
|
}
|
|
67
64
|
</style>
|
|
68
65
|
</head>
|
|
69
66
|
<body>
|
|
70
|
-
|
|
71
|
-
<
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
<div class="
|
|
75
|
-
<div class="bubble">
|
|
76
|
-
{userData.message}
|
|
77
|
-
</div>
|
|
67
|
+
<div id="target-element" class="message-card">
|
|
68
|
+
<img src="{userData.avatarUrl}" class="avatar" />
|
|
69
|
+
<div class="content">
|
|
70
|
+
<div class="user-name">{userData.username}</div>
|
|
71
|
+
<div class="text-bubble">{userData.message}</div>
|
|
78
72
|
</div>
|
|
79
73
|
</div>
|
|
80
74
|
</body>
|