koishi-plugin-node-async-bot-all 2.20.0 → 2.20.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/index.js +9 -4
- package/package.json +1 -1
- package/res/userMsg.html +36 -42
package/lib/index.js
CHANGED
|
@@ -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:");
|
|
@@ -702,11 +702,16 @@ async function getMsg(ctx, session) {
|
|
|
702
702
|
const html = await readUserMsgFile(user.name, user.avatar, msg);
|
|
703
703
|
try {
|
|
704
704
|
await page.setViewport({
|
|
705
|
-
width:
|
|
706
|
-
height:
|
|
705
|
+
width: 450,
|
|
706
|
+
height: 1,
|
|
707
707
|
deviceScaleFactor: 2
|
|
708
708
|
});
|
|
709
709
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
710
|
+
const { width, height } = await page.evaluate(() => ({
|
|
711
|
+
width: document.body.scrollWidth + 50,
|
|
712
|
+
height: document.body.scrollHeight
|
|
713
|
+
}));
|
|
714
|
+
await page.setViewport({ width, height, deviceScaleFactor: 2 });
|
|
710
715
|
const element = await page.$("#target-element");
|
|
711
716
|
if (element) {
|
|
712
717
|
const image = await element.screenshot({
|
|
@@ -733,7 +738,7 @@ async function getMsg(ctx, session) {
|
|
|
733
738
|
__name(getMsg, "getMsg");
|
|
734
739
|
|
|
735
740
|
// package.json
|
|
736
|
-
var version = "2.20.
|
|
741
|
+
var version = "2.20.1";
|
|
737
742
|
|
|
738
743
|
// src/index.ts
|
|
739
744
|
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>
|