koishi-plugin-node-async-bot-all 2.26.0 → 2.26.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/fun.d.ts +1 -1
- package/lib/index.js +9 -6
- package/package.json +1 -1
- package/res/userMsg.html +45 -11
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
|
@@ -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({
|
|
@@ -931,13 +934,13 @@ __name(getNewsMsg, "getNewsMsg");
|
|
|
931
934
|
async function getUse(ctx, session, qq, desc) {
|
|
932
935
|
const log = ctx.logger("getUse");
|
|
933
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}"}`);
|
|
934
|
-
await session.send(session.text(".msg", { "at": import_koishi2.h.at(session.event.user?.id), "at2": import_koishi2.h.at(qq), "desc": desc ?? "使用" }));
|
|
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"/>', "")) ?? "使用" }));
|
|
935
938
|
return 0;
|
|
936
939
|
}
|
|
937
940
|
__name(getUse, "getUse");
|
|
938
941
|
|
|
939
942
|
// package.json
|
|
940
|
-
var version = "2.26.
|
|
943
|
+
var version = "2.26.2";
|
|
941
944
|
|
|
942
945
|
// src/index.ts
|
|
943
946
|
var inject = ["database", "installer", "puppeteer", "cron"];
|
package/package.json
CHANGED
package/res/userMsg.html
CHANGED
|
@@ -9,11 +9,10 @@
|
|
|
9
9
|
body {
|
|
10
10
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
11
11
|
background: transparent;
|
|
12
|
-
padding: 20px;
|
|
13
|
-
//// transform: rotate(180deg);
|
|
12
|
+
padding: 20px;
|
|
13
|
+
//// transform: rotate(180deg);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
/* 核心容器 */
|
|
17
16
|
.message-card {
|
|
18
17
|
display: flex;
|
|
19
18
|
flex-direction: row;
|
|
@@ -22,31 +21,58 @@
|
|
|
22
21
|
background: #ffffff;
|
|
23
22
|
padding: 15px;
|
|
24
23
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
24
|
+
border-radius: 8px;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
/* 头像样式 */
|
|
28
27
|
.avatar {
|
|
29
28
|
width: 50px;
|
|
30
29
|
height: 50px;
|
|
31
30
|
border-radius: 50%;
|
|
32
31
|
object-fit: cover;
|
|
33
|
-
flex-shrink: 0;
|
|
32
|
+
flex-shrink: 0;
|
|
34
33
|
margin-right: 15px;
|
|
35
34
|
border: 1px solid #eee;
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
/* 消息气泡样式 */
|
|
39
37
|
.content {
|
|
40
38
|
flex: 1;
|
|
41
39
|
display: flex;
|
|
42
40
|
flex-direction: column;
|
|
41
|
+
min-width: 0;
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
.user-name {
|
|
46
45
|
font-weight: bold;
|
|
47
46
|
font-size: 14px;
|
|
48
47
|
color: #333;
|
|
49
|
-
margin-bottom:
|
|
48
|
+
margin-bottom: 6px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.reply-block {
|
|
52
|
+
background: #f7f8fa;
|
|
53
|
+
border-left: 3px solid #b9bbbe;
|
|
54
|
+
padding: 6px 10px;
|
|
55
|
+
border-radius: 0 4px 4px 0;
|
|
56
|
+
margin-bottom: 8px;
|
|
57
|
+
/**/display:none;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.reply-user {
|
|
61
|
+
font-size: 12px;
|
|
62
|
+
font-weight: 600;
|
|
63
|
+
color: #555;
|
|
64
|
+
margin-bottom: 3px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.reply-text {
|
|
68
|
+
font-size: 13px;
|
|
69
|
+
color: #777;
|
|
70
|
+
display: -webkit-box;
|
|
71
|
+
-webkit-line-clamp: 2;
|
|
72
|
+
-webkit-box-orient: vertical;
|
|
73
|
+
overflow: hidden;
|
|
74
|
+
text-overflow: ellipsis;
|
|
75
|
+
word-break: break-all;
|
|
50
76
|
}
|
|
51
77
|
|
|
52
78
|
.text-bubble {
|
|
@@ -55,20 +81,28 @@
|
|
|
55
81
|
color: #444;
|
|
56
82
|
background: #f2f3f5;
|
|
57
83
|
padding: 10px 14px;
|
|
58
|
-
border-radius: 0 12px 12px 12px;
|
|
84
|
+
border-radius: 0 12px 12px 12px;
|
|
59
85
|
|
|
60
|
-
white-space: pre-wrap;
|
|
61
|
-
word-wrap: break-word;
|
|
86
|
+
white-space: pre-wrap;
|
|
87
|
+
word-wrap: break-word;
|
|
62
88
|
overflow-wrap: break-word;
|
|
63
89
|
word-break: break-all;
|
|
90
|
+
width: fit-content;
|
|
64
91
|
}
|
|
65
92
|
</style>
|
|
66
93
|
</head>
|
|
67
94
|
<body>
|
|
68
95
|
<div id="target-element" class="message-card">
|
|
69
|
-
<img src="{userData.avatarUrl}" class="avatar" />
|
|
96
|
+
<img src="{userData.avatarUrl}" class="avatar" alt="Avatar" />
|
|
70
97
|
<div class="content">
|
|
71
98
|
<div class="user-name">{userData.username}</div>
|
|
99
|
+
|
|
100
|
+
<!-- 新增的回复块 -->
|
|
101
|
+
<div class="reply-block">
|
|
102
|
+
<div class="reply-user">@{replyData.username}</div>
|
|
103
|
+
<div class="reply-text">{replyData.message}</div>
|
|
104
|
+
</div>
|
|
105
|
+
|
|
72
106
|
<div class="text-bubble">{userData.message}</div>
|
|
73
107
|
</div>
|
|
74
108
|
</div>
|