koishi-plugin-csss 4.1.2 → 4.1.3
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.d.ts +0 -1
- package/lib/index.js +6 -66
- package/package.json +3 -3
- package/readme.md +2 -2
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -38,7 +38,6 @@ var Config = import_koishi.Schema.object({
|
|
|
38
38
|
generateImage: import_koishi.Schema.boolean().default(true).description("是否生成图片横幅(影响cs和csss命令)"),
|
|
39
39
|
imageWidth: import_koishi.Schema.number().min(600).max(2e3).default(1200).description("图片宽度(像素)"),
|
|
40
40
|
imageHeight: import_koishi.Schema.number().min(200).max(2500).default(500).description("图片最小高度(像素),实际高度会根据内容自适应"),
|
|
41
|
-
fontFamily: import_koishi.Schema.string().default("JetBrains Mono, monospace").description("字体"),
|
|
42
41
|
customHTML: import_koishi.Schema.string().role("textarea").description("自定义单个服务器查询的HTML模板,支持占位符:{{SERVER_NAME}}, {{MAP}}, {{PLAYERS_COUNT}}, {{MAX_PLAYERS}}, {{BOT_COUNT}}, {{PING}}, {{HOST}}, {{PORT}}, {{PLAYERS_LIST}}, {{TIMESTAMP}}").default(""),
|
|
43
42
|
customBatchHTML: import_koishi.Schema.string().role("textarea").description("自定义批量查询的HTML模板,支持占位符:{{TOTAL}}, {{SUCCESSFUL}}, {{QUERY_TIME}}, {{SERVERS_LIST}}, {{TIMESTAMP}}").default("")
|
|
44
43
|
});
|
|
@@ -265,33 +264,13 @@ function apply(ctx, config) {
|
|
|
265
264
|
}
|
|
266
265
|
__name(formatPlayers, "formatPlayers");
|
|
267
266
|
function getBaseCSS() {
|
|
268
|
-
return
|
|
269
|
-
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
270
|
-
body {
|
|
271
|
-
background: #1c1c1fcc;
|
|
272
|
-
font-family: ${config.fontFamily};
|
|
273
|
-
width: ${config.imageWidth}px;
|
|
274
|
-
min-height: ${config.imageHeight}px;
|
|
275
|
-
padding: 40px;
|
|
276
|
-
color: #71717a;
|
|
277
|
-
position: relative;
|
|
278
|
-
border: 2px solid #2e2e33;
|
|
279
|
-
font-size: 24px;
|
|
280
|
-
}
|
|
281
|
-
.corner { position: absolute; width: 25px; height: 25px; border-color: #fbbf24; border-style: solid; border-width: 0; }
|
|
282
|
-
.corner-tl { top: 2px; left: 2px; border-top-width: 3px; border-left-width: 3px; }
|
|
283
|
-
.corner-tr { top: 2px; right: 2px; border-top-width: 3px; border-right-width: 3px; }
|
|
284
|
-
.corner-bl { bottom: 2px; left: 2px; border-bottom-width: 3px; border-left-width: 3px; }
|
|
285
|
-
.corner-br { bottom: 2px; right: 2px; border-bottom-width: 3px; border-right-width: 3px; }
|
|
286
|
-
.divider { height: 2px; background: #2e2e33; margin: 20px 0; }
|
|
287
|
-
.timestamp { margin-top: 30px; font-size: 0.8em; color: #666666; text-align: left; }
|
|
288
|
-
`;
|
|
267
|
+
return `:root{--ink:#eef2f5;--ink-dim:#b7bdc7;--line-strong:#d5dae1;--panel:rgba(15,18,24,0.56)}*{box-sizing:border-box}html,body{width:100%;min-height:100%}body{margin:0;color:var(--ink);font-family:"Chakra Petch","Noto Sans SC",sans-serif;background:radial-gradient(circle at 12% 18%,#1f242e 0,transparent 46%),radial-gradient(circle at 84% 92%,#171b24 0,transparent 42%),linear-gradient(160deg,#050607 0%,#0a0d12 48%,#060708 100%);overflow-x:hidden}.atmosphere{position:absolute;inset:0;pointer-events:none;z-index:0;background:repeating-linear-gradient(90deg,rgba(174,181,190,0.08) 0,rgba(174,181,190,0.08) 1px,transparent 1px,transparent 62px),repeating-linear-gradient(0deg,rgba(174,181,190,0.05) 0,rgba(174,181,190,0.05) 1px,transparent 1px,transparent 62px)}.shell{position:relative;z-index:8;width:min(1000px,92vw);margin:0 auto;padding:clamp(42px,8.4vh,78px) 0 52px}.hero{margin-bottom:22px;max-width:980px}.eyebrow{margin:0 0 9px;font-family:"Orbitron",sans-serif;letter-spacing:0.19em;font-size:clamp(0.68rem,1.1vw,0.82rem);color:var(--ink-dim)}.hero-title-wrap{display:flex;align-items:flex-start;gap:12px}.brand-stack{display:flex;flex-direction:column;gap:2px}.hero h1{margin:0;font-family:"Orbitron",sans-serif;font-size:clamp(1.05rem,2vw,1.4rem);letter-spacing:0.08em;line-height:1.2;text-shadow:0 0 12px rgba(204,212,224,0.18)}.server-grid{display:grid;gap:14px}.server-item{border:1px solid rgba(205,213,221,0.32);background:linear-gradient(145deg,rgba(255,255,255,0.09),rgba(255,255,255,0.01)),var(--panel);padding:15px 16px 16px;position:relative;overflow:hidden;box-shadow:inset 0 0 0 1px rgba(255,255,255,0.09),0 10px 32px rgba(0,0,0,0.35)}.server-item .server-header{margin:0;font-family:"Orbitron",sans-serif;font-size:clamp(0.88rem,1.45vw,1rem);font-weight:600;letter-spacing:0.04em;line-height:1.38;overflow-wrap:anywhere}.server-item .server-header .server-players{float:right}.server-item .server-ping{float:right}.border{margin-top:12px;border-top:1px solid rgba(220,229,240,0.2)}.server-addr{margin:10px 0 8px;color:var(--line-strong);font-size:clamp(0.9rem,1.4vw,1rem);letter-spacing:0.02em;word-break:break-all;display:block}.site-footer{margin-top:20px;padding-top:12px;border-top:1px solid rgba(220,229,240,0.2)}.site-footer p{margin:0;color:var(--ink-dim);font-size:0.92rem;letter-spacing:0.05em}.site-footer .footer-note{margin-top:8px;font-size:0.84rem;line-height:1.6;color:rgba(197,206,217,0.95)}`;
|
|
289
268
|
}
|
|
290
269
|
__name(getBaseCSS, "getBaseCSS");
|
|
291
270
|
function buildPlayersListHTML(players) {
|
|
292
271
|
const pCount = players.length;
|
|
293
272
|
if (pCount === 0) {
|
|
294
|
-
return `<div class="player-row"
|
|
273
|
+
return `<div class="player-row">服务器当前无玩家在线</div>`;
|
|
295
274
|
}
|
|
296
275
|
const sorted = [...players].sort((a, b) => utils.cleanName(a.name).localeCompare(utils.cleanName(b.name))).slice(0, config.maxPlayers);
|
|
297
276
|
const isTwoCols = pCount > 10;
|
|
@@ -300,13 +279,13 @@ function apply(ctx, config) {
|
|
|
300
279
|
const renderCol = /* @__PURE__ */ __name((arr) => arr.map((p) => `<div class="player-row">${utils.escapeHtml(utils.truncateText(utils.cleanName(p.name), 20))}</div>`).join(""), "renderCol");
|
|
301
280
|
let html = `<div style="display: flex; gap: 40px;"><div>${renderCol(sorted.slice(0, half))}</div><div>${renderCol(sorted.slice(half))}</div></div>`;
|
|
302
281
|
if (pCount > config.maxPlayers) {
|
|
303
|
-
html += `<div class="player-row"
|
|
282
|
+
html += `<div class="player-row">... 还有 ${pCount - config.maxPlayers} 位玩家未显示</div>`;
|
|
304
283
|
}
|
|
305
284
|
return html;
|
|
306
285
|
} else {
|
|
307
286
|
let html = sorted.map((p) => `<div class="player-row">${utils.escapeHtml(utils.truncateText(utils.cleanName(p.name), 20))}</div>`).join("");
|
|
308
287
|
if (pCount > config.maxPlayers) {
|
|
309
|
-
html += `<div class="player-row"
|
|
288
|
+
html += `<div class="player-row">... 还有 ${pCount - config.maxPlayers} 位玩家未显示</div>`;
|
|
310
289
|
}
|
|
311
290
|
return html;
|
|
312
291
|
}
|
|
@@ -315,24 +294,7 @@ function apply(ctx, config) {
|
|
|
315
294
|
function generateDefaultServerHTML(data, host, port) {
|
|
316
295
|
const r = data.result;
|
|
317
296
|
const playersHTML = buildPlayersListHTML(r.players);
|
|
318
|
-
return `<!DOCTYPE html><html><head><meta charset="UTF-8"><style>
|
|
319
|
-
${getBaseCSS()}
|
|
320
|
-
.title { text-align: center; font-size: 1.5em; color: #71717a; margin-bottom: 20px; }
|
|
321
|
-
.server-name { text-align: center; font-size: 1.8em; font-weight: bold; color: #fbbf24; margin: 10px 0 20px; word-break: break-word; }
|
|
322
|
-
.info-row { display: flex; justify-content: space-between; margin: 15px 0; font-size: 1em; }
|
|
323
|
-
.player-section { margin-top: 20px; }
|
|
324
|
-
.player-section-title { font-size: 1em; font-weight: bold; color: #fcf8de; margin-bottom: 10px; }
|
|
325
|
-
.player-row { font-size: 0.9em; color: #dddddd; line-height: 1.8; }
|
|
326
|
-
</style></head><body>
|
|
327
|
-
<div class="corner corner-tl"></div><div class="corner corner-tr"></div><div class="corner corner-bl"></div><div class="corner corner-br"></div>
|
|
328
|
-
<div class="title">[服务器状态查询]</div>
|
|
329
|
-
<div class="server-name">${utils.escapeHtml(utils.cleanName(r.name || "未知服务器"))}</div>
|
|
330
|
-
<div class="divider"></div>
|
|
331
|
-
<div class="info-row"><span>地图: ${utils.escapeHtml(r.map || "未知")}</span><span>IP: ${utils.escapeHtml(`${host}:${port}`)}</span></div>
|
|
332
|
-
<div class="info-row"><span style="color: ${utils.getPlayerColor(r.players.length)};">人数: ${r.players.length}/${r.maxplayers}${r.bots.length ? ` (${r.bots.length} Bot)` : ""}</span><span style="color: ${utils.getPingColor(r.ping)};">Ping: ${r.ping ? r.ping + "ms" : "未知"}</span></div>
|
|
333
|
-
<div class="player-section"><div class="player-section-title">在线玩家</div><div class="divider" style="margin: 5px 0 15px;"></div>${playersHTML}</div>
|
|
334
|
-
<div class="timestamp">查询时间: ${(/* @__PURE__ */ new Date()).toLocaleString("zh-CN")}</div>
|
|
335
|
-
</body></html>`;
|
|
297
|
+
return `<!DOCTYPE html><html><head><meta charset="UTF-8"><style>${getBaseCSS()}.server-grid{grid-template-columns:1fr}.player-row{margin-top:12px;font-size:0.9rem;color:#aaaaaa}</style></head><body><div class="atmosphere"aria-hidden="true"></div><main class="shell"><header class="hero"><p class="eyebrow">SERVER STATUS</p><div class="hero-title-wrap"><div class="brand-stack"><h1>服务器状态</h1></div></div></header><section class="server-grid"><div class="server-item"><div class="server-header"><span class="server-name">${utils.escapeHtml(utils.cleanName(r.name || "未知服务器"))}</span><span class="server-players"style="color: ${utils.getPlayerColor(r.players.length)};">${r.players.length}/${r.maxplayers}${r.bots.length ? `(${r.bots.length}Bot)` : ""}</span></div><div class="server-details"><span class="server-addr">IP:${utils.escapeHtml(host)}</span></div><div class="server-details"><span class="server-map">地图:${utils.escapeHtml(r.map || "未知")}</span><span class="server-ping"style="color: ${utils.getPingColor(r.ping)};">延迟:${r.ping ? r.ping + "ms" : "未知"}</span></div><div class="border"></div>${playersHTML}</section><footer class="site-footer"aria-label="社区信息"><p class="footer-note">查询时间:${(/* @__PURE__ */ new Date()).toLocaleString()}</p></footer></main></body></html>`;
|
|
336
298
|
}
|
|
337
299
|
__name(generateDefaultServerHTML, "generateDefaultServerHTML");
|
|
338
300
|
function renderCustomServerHTML(data, host, port, template) {
|
|
@@ -373,29 +335,7 @@ function apply(ctx, config) {
|
|
|
373
335
|
<div class="server-details error-msg">${utils.escapeHtml(result.error || "未知错误")}</div>
|
|
374
336
|
</div>`;
|
|
375
337
|
}).join("");
|
|
376
|
-
return `<!DOCTYPE html><html><head><meta charset="UTF-8"><style>
|
|
377
|
-
${getBaseCSS()}
|
|
378
|
-
.title { text-align: center; font-size: 1.8em; color: #71717a; margin-bottom: 20px; font-weight: bold; }
|
|
379
|
-
.stats { display: flex; justify-content: space-between; font-size: 1em; margin-bottom: 10px; }
|
|
380
|
-
.divider { background: #FFD700; margin: 15px 0 30px; }
|
|
381
|
-
.server-item { margin-bottom: 30px; border-bottom: 1px solid #555555; padding-bottom: 20px; }
|
|
382
|
-
.server-item:last-child { border-bottom: none; }
|
|
383
|
-
.server-header { display: flex; align-items: center; gap: 10px; font-size: 1.2em; font-weight: bold; color: #ffffff; margin-bottom: 8px; }
|
|
384
|
-
.server-index { color: #fbbf24; }
|
|
385
|
-
.server-players { margin-left: auto; }
|
|
386
|
-
.server-details { display: flex; flex-wrap: wrap; gap: 20px; font-size: 0.9em; color: #aaaaaa; position: relative; }
|
|
387
|
-
.server-details span { white-space: nowrap; }
|
|
388
|
-
.server-details .server-ping {position: absolute;right: 0;font-size: 24px;}
|
|
389
|
-
.error .server-name { color: #c03f36; }
|
|
390
|
-
.error-msg { color: #c03f36; font-size: 1em; }
|
|
391
|
-
</style></head><body>
|
|
392
|
-
<div class="corner corner-tl"></div><div class="corner corner-tr"></div><div class="corner corner-bl"></div><div class="corner corner-br"></div>
|
|
393
|
-
<div class="title">[服务器状态批量查询]</div>
|
|
394
|
-
<div class="stats"><span>查询时间: ${(/* @__PURE__ */ new Date()).toLocaleString("zh-CN")}</span><span>耗时: ${utils.formatTime(queryTime)} | 成功: ${successful}/${results.length}</span></div>
|
|
395
|
-
<div class="divider"></div>
|
|
396
|
-
${serversHTML}
|
|
397
|
-
<div class="timestamp">📋 输入 \`cs 服务器地址\` 查询单个服务器</div>
|
|
398
|
-
</body></html>`;
|
|
338
|
+
return `<!DOCTYPE html><html><head><meta charset="UTF-8"><style>${getBaseCSS()}.server-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.subtitle{margin:8px 0 0;font-size:clamp(0.95rem,1.65vw,1.12rem);line-height:1.55;color:var(--ink-dim);max-width:760px}.error-msg{color:rgba(255,107,107,0.95);margin:10px 0 8px;font-size:clamp(0.9rem,1.4vw,1rem);letter-spacing:0.02em;word-break:break-all}}</style></head><body><div class="atmosphere"aria-hidden="true"></div><main class="shell"><header class="hero"><p class="eyebrow">SERVER DIRECTORY</p><div class="hero-title-wrap"><div class="brand-stack"><h1>服务器列表</h1></div></div><p class="subtitle">查询耗时:${utils.formatTime(queryTime)}|成功:${successful}/${results.length}</p></header><section class="server-grid">${serversHTML}</section><footer class="site-footer"aria-label="社区信息"><p class="footer-note">查询时间:${(/* @__PURE__ */ new Date()).toLocaleString()}</p><p>📋输入\`cs服务器地址\`查询单个服务器</p></footer></main></body></html>`;
|
|
399
339
|
}
|
|
400
340
|
__name(generateDefaultBatchHTML, "generateDefaultBatchHTML");
|
|
401
341
|
function buildServersListHTML(results, serversToQuery) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-csss",
|
|
3
3
|
"description": "一个用于 Koishi 的 CS:GO / CS2 服务器状态查询插件,支持单个/批量查询、服务器列表管理,并可将结果渲染为图片",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.3",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"homepage": "https://github.com/Sanksu/koishi-plugin-csss",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "https://github.com/Sanksu/koishi-plugin-csss"
|
|
15
|
+
"url": "git+https://github.com/Sanksu/koishi-plugin-csss.git"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
18
|
"chatbot",
|
|
@@ -61,4 +61,4 @@
|
|
|
61
61
|
]
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
}
|
|
64
|
+
}
|
package/readme.md
CHANGED
|
@@ -121,7 +121,7 @@ csss -c #清空数据库中的服务器列表
|
|
|
121
121
|
无玩家时:
|
|
122
122
|
|
|
123
123
|
```html
|
|
124
|
-
<div class="player-row"
|
|
124
|
+
<div class="player-row"">服务器当前无玩家在线</div>
|
|
125
125
|
```
|
|
126
126
|
|
|
127
127
|
有玩家时(玩家数超过 10 人会自动分为两列显示,通过 display: flex 布局):
|
|
@@ -130,7 +130,7 @@ csss -c #清空数据库中的服务器列表
|
|
|
130
130
|
<div class="player-row">Player1</div>
|
|
131
131
|
<div class="player-row">Player2</div>
|
|
132
132
|
<!-- 超过 maxPlayers 时追加 -->
|
|
133
|
-
<div class="player-row"
|
|
133
|
+
<div class="player-row">... 还有 N 位玩家未显示</div>
|
|
134
134
|
```
|
|
135
135
|
|
|
136
136
|
|