koishi-plugin-rocom 1.0.4 → 1.0.6
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/client.js +1 -1
- package/lib/commands/account.js +41 -3
- package/lib/commands/admin.js +27 -5
- package/lib/commands/merchant.js +73 -38
- package/lib/index.js +145 -3815
- package/lib/render-templates/yuanxing-shangren/index.html +29 -29
- package/lib/subscription-send.d.ts +2 -1
- package/lib/subscription-send.js +13 -0
- package/lib/user.d.ts +1 -0
- package/package.json +2 -2
- package/readme.md +22 -10
|
@@ -44,7 +44,7 @@ body {
|
|
|
44
44
|
|
|
45
45
|
.merchant-page {
|
|
46
46
|
position: relative;
|
|
47
|
-
width: min(
|
|
47
|
+
width: min(1280px, 100%);
|
|
48
48
|
margin: 0 auto;
|
|
49
49
|
overflow: hidden;
|
|
50
50
|
background: #ece3d3;
|
|
@@ -91,8 +91,8 @@ body {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
.title-badge {
|
|
94
|
-
width:
|
|
95
|
-
height:
|
|
94
|
+
width: 56px;
|
|
95
|
+
height: 56px;
|
|
96
96
|
display: flex;
|
|
97
97
|
align-items: center;
|
|
98
98
|
justify-content: center;
|
|
@@ -103,8 +103,8 @@ body {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
.title-badge img {
|
|
106
|
-
width:
|
|
107
|
-
height:
|
|
106
|
+
width: 56px;
|
|
107
|
+
height: 56px;
|
|
108
108
|
object-fit: contain;
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -176,11 +176,11 @@ body {
|
|
|
176
176
|
|
|
177
177
|
.product-card {
|
|
178
178
|
display: grid;
|
|
179
|
-
grid-template-columns:
|
|
179
|
+
grid-template-columns: 120px 1fr auto;
|
|
180
180
|
gap: 18px;
|
|
181
181
|
align-items: center;
|
|
182
|
-
min-height:
|
|
183
|
-
padding: 18px
|
|
182
|
+
min-height: 148px;
|
|
183
|
+
padding: 18px 28px;
|
|
184
184
|
border: 1px solid rgba(118, 97, 74, 0.14);
|
|
185
185
|
border-radius: 22px;
|
|
186
186
|
background: linear-gradient(135deg, rgba(255,255,255,0.72), rgba(244,236,224,0.88));
|
|
@@ -188,9 +188,9 @@ body {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
.product-image-container {
|
|
191
|
-
width:
|
|
192
|
-
height:
|
|
193
|
-
border-radius:
|
|
191
|
+
width: 120px;
|
|
192
|
+
height: 120px;
|
|
193
|
+
border-radius: 50%;
|
|
194
194
|
background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.94), rgba(239,228,210,0.92));
|
|
195
195
|
display: flex;
|
|
196
196
|
align-items: center;
|
|
@@ -295,14 +295,14 @@ body {
|
|
|
295
295
|
}
|
|
296
296
|
|
|
297
297
|
.product-card {
|
|
298
|
-
grid-template-columns:
|
|
298
|
+
grid-template-columns: 80px 1fr;
|
|
299
299
|
min-height: 0;
|
|
300
300
|
padding: 12px 14px;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
.product-image-container {
|
|
304
|
-
width:
|
|
305
|
-
height:
|
|
304
|
+
width: 80px;
|
|
305
|
+
height: 80px;
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
.product-name {
|
|
@@ -312,7 +312,7 @@ body {
|
|
|
312
312
|
.product-side {
|
|
313
313
|
grid-column: 1 / -1;
|
|
314
314
|
justify-content: flex-start;
|
|
315
|
-
padding-left:
|
|
315
|
+
padding-left: 94px;
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
</style>
|
|
@@ -325,11 +325,11 @@ body {
|
|
|
325
325
|
<div class="title-section">
|
|
326
326
|
<div class="title-main">
|
|
327
327
|
<div class="title-badge">
|
|
328
|
-
{{if titleIcon}}
|
|
329
|
-
<img src="{{_res_path}}img/yuanxingshangren.png" alt="{{title}}">
|
|
330
|
-
{{else}}
|
|
331
|
-
远
|
|
332
|
-
{{/if}}
|
|
328
|
+
{{if titleIcon}}
|
|
329
|
+
<img src="{{_res_path}}img/yuanxingshangren.png" alt="{{title}}">
|
|
330
|
+
{{else}}
|
|
331
|
+
远
|
|
332
|
+
{{/if}}
|
|
333
333
|
</div>
|
|
334
334
|
<span class="title-text">{{title}}</span>
|
|
335
335
|
</div>
|
|
@@ -338,16 +338,16 @@ body {
|
|
|
338
338
|
<div class="header-side">
|
|
339
339
|
<div class="summary-chip">当前商品数 <strong>{{product_count}}</strong></div>
|
|
340
340
|
<div class="round-info">
|
|
341
|
-
<div class="round-pill">第 {{round_info.current || '未开放'}} / {{round_info.total}} 轮</div>
|
|
341
|
+
<div class="round-pill">第 {{round_info.current || '未开放'}} / {{round_info.total}} 轮</div>
|
|
342
342
|
<div class="countdown-pill">剩余 {{round_info.countdown}}</div>
|
|
343
343
|
</div>
|
|
344
344
|
</div>
|
|
345
345
|
</div>
|
|
346
346
|
|
|
347
347
|
<div class="products-grid">
|
|
348
|
-
{{if products && products.length > 0}}
|
|
349
|
-
{{each products product}}
|
|
350
|
-
<div class="product-card">
|
|
348
|
+
{{if products && products.length > 0}}
|
|
349
|
+
{{each products product}}
|
|
350
|
+
<div class="product-card">
|
|
351
351
|
<div class="product-image-container">
|
|
352
352
|
<img class="product-image" src="{{product.image}}" alt="{{product.name}}">
|
|
353
353
|
</div>
|
|
@@ -359,11 +359,11 @@ body {
|
|
|
359
359
|
<div class="product-side">
|
|
360
360
|
<div class="product-slot">本轮商品</div>
|
|
361
361
|
</div>
|
|
362
|
-
</div>
|
|
363
|
-
{{/each}}
|
|
364
|
-
{{else}}
|
|
365
|
-
<div class="product-empty">本轮暂无商品,稍后再来看看。</div>
|
|
366
|
-
{{/if}}
|
|
362
|
+
</div>
|
|
363
|
+
{{/each}}
|
|
364
|
+
{{else}}
|
|
365
|
+
<div class="product-empty">本轮暂无商品,稍后再来看看。</div>
|
|
366
|
+
{{/if}}
|
|
367
367
|
</div>
|
|
368
368
|
</div>
|
|
369
369
|
</div>
|
|
@@ -5,4 +5,5 @@ export interface SubscriptionTarget {
|
|
|
5
5
|
guildId?: string;
|
|
6
6
|
userId?: string;
|
|
7
7
|
}
|
|
8
|
-
export declare function sendScheduledMessage(ctx: Context, target: SubscriptionTarget, message:
|
|
8
|
+
export declare function sendScheduledMessage(ctx: Context, target: SubscriptionTarget, message: any): Promise<boolean>;
|
|
9
|
+
export declare function sendScheduledImageWithFallback(ctx: Context, target: SubscriptionTarget, image: Buffer | null, fallbackText: string, mentionAll?: boolean): Promise<boolean>;
|
package/lib/subscription-send.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sendScheduledMessage = sendScheduledMessage;
|
|
4
|
+
exports.sendScheduledImageWithFallback = sendScheduledImageWithFallback;
|
|
4
5
|
const koishi_1 = require("koishi");
|
|
5
6
|
const logger = new koishi_1.Logger('rocom-subscription-send');
|
|
6
7
|
function findBot(ctx, platform = '') {
|
|
@@ -46,3 +47,15 @@ async function sendScheduledMessage(ctx, target, message) {
|
|
|
46
47
|
logger.warn(`scheduled push target is incomplete: ${JSON.stringify(target)}`);
|
|
47
48
|
return false;
|
|
48
49
|
}
|
|
50
|
+
async function sendScheduledImageWithFallback(ctx, target, image, fallbackText, mentionAll = false) {
|
|
51
|
+
const prefix = mentionAll ? '@全体\n' : '';
|
|
52
|
+
if (!image) {
|
|
53
|
+
return sendScheduledMessage(ctx, target, `${prefix}${fallbackText}`);
|
|
54
|
+
}
|
|
55
|
+
const imageSegment = koishi_1.h.image(image, 'image/png');
|
|
56
|
+
const content = mentionAll ? `${prefix}${imageSegment}` : imageSegment;
|
|
57
|
+
const sent = await sendScheduledMessage(ctx, target, content);
|
|
58
|
+
if (sent)
|
|
59
|
+
return true;
|
|
60
|
+
return sendScheduledMessage(ctx, target, `${prefix}${fallbackText}`);
|
|
61
|
+
}
|
package/lib/user.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-rocom",
|
|
3
3
|
"description": "洛克王国查询与订阅插件",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.6",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"homepage": "https://github.com/staytomorrow/koishi-plugin-rocom",
|
|
@@ -53,6 +53,6 @@
|
|
|
53
53
|
"database"
|
|
54
54
|
]
|
|
55
55
|
},
|
|
56
|
-
"preview":
|
|
56
|
+
"preview": false
|
|
57
57
|
}
|
|
58
58
|
}
|
package/readme.md
CHANGED
|
@@ -16,7 +16,7 @@ Koishi 版洛克王国数据查询插件。插件基于 WeGame / 后端接口提
|
|
|
16
16
|
| --- | --- |
|
|
17
17
|
| 账号管理 | QQ 扫码登录、微信扫码登录、凭证导入、绑定列表、切换账号、解绑、刷新凭证 |
|
|
18
18
|
| 数据查询 | 档案、战绩、背包、阵容推荐、阵容详情、交换大厅 |
|
|
19
|
-
| 商人提醒 |
|
|
19
|
+
| 商人提醒 | 远行商人查询、商品关键词订阅、全部订阅(每轮直推整图)、查看订阅、取消订阅 |
|
|
20
20
|
| 百科查询 | 精灵 Wiki、技能 Wiki |
|
|
21
21
|
| 查蛋配种 | 精灵查蛋、尺寸反查、候选结果、目标配种方案、配种判定 |
|
|
22
22
|
| 管理维护 | 刷新所有凭证、删除失效绑定、自动刷新凭证 |
|
|
@@ -275,23 +275,34 @@ Koishi 版洛克王国数据查询插件。插件基于 WeGame / 后端接口提
|
|
|
275
275
|
|
|
276
276
|
> 图片位置:远行商人商品截图。建议插入 `docs/images/merchant-current.png`。
|
|
277
277
|
|
|
278
|
-
### `订阅远行商人 [商品名...]`
|
|
278
|
+
### `订阅远行商人 [1/0] [商品名... | 全部]`
|
|
279
279
|
|
|
280
|
-
|
|
280
|
+
在群聊中订阅远行商人提醒。群内操作仅 `adminUserIds` 中配置的 Bot 管理员可设置;私聊场景支持个人自行订阅(需开启 `merchantPrivateSubscriptionEnabled`)。
|
|
281
281
|
|
|
282
|
-
|
|
282
|
+
参数说明:
|
|
283
|
+
|
|
284
|
+
- 第一个可选参数 `1` / `0`:仅群聊生效。`1` 表示命中后 @全体成员,`0` 表示不 @全体。省略时默认 `0`。私聊订阅强制为不 @。
|
|
285
|
+
- 后续参数为订阅商品名,按"包含关系"与当前商品名做模糊匹配(例如订阅 `国王球` 会命中 `国王球(大)`)。
|
|
286
|
+
- 若只传一个特殊关键字 `全部`,则进入 **全部订阅模式**:忽略商品匹配,只要远行商人本轮有在售商品,就把整张远行商人渲染图直接推送给订阅方。每轮(`08:00 / 12:00 / 16:00 / 20:00`)只推一次。
|
|
287
|
+
- 不传任何商品名时,使用配置里的 `merchantSubscriptionItems` 作为默认关键词。
|
|
288
|
+
|
|
289
|
+
查看当前会话的订阅:
|
|
283
290
|
|
|
284
291
|
```text
|
|
285
|
-
|
|
292
|
+
查看远行商人订阅
|
|
286
293
|
```
|
|
287
294
|
|
|
288
|
-
|
|
295
|
+
常见用法:
|
|
289
296
|
|
|
290
297
|
```text
|
|
291
|
-
订阅远行商人
|
|
298
|
+
订阅远行商人 # 使用配置中的默认关键词
|
|
299
|
+
订阅远行商人 国王球 棱镜球 炫彩精灵蛋 # 按关键词匹配
|
|
300
|
+
订阅远行商人 1 国王球 # 命中后 @全体
|
|
301
|
+
订阅远行商人 全部 # 每轮直接推送整张商人图
|
|
302
|
+
订阅远行商人 1 全部 # 每轮推送并 @全体
|
|
292
303
|
```
|
|
293
304
|
|
|
294
|
-
|
|
305
|
+
按关键词订阅时,去重规则是"同一轮次 + 同一匹配商品集合"只推一次;全部订阅模式下仅按轮次去重,本轮推过就不再重复。
|
|
295
306
|
|
|
296
307
|
> 图片位置:订阅远行商人结果截图。建议插入 `docs/images/merchant-subscribe.png`。
|
|
297
308
|
|
|
@@ -537,8 +548,9 @@ autoRefreshTime:
|
|
|
537
548
|
请检查:
|
|
538
549
|
|
|
539
550
|
- `merchantSubscriptionEnabled` 是否开启。
|
|
540
|
-
-
|
|
541
|
-
-
|
|
551
|
+
- 会话是否已经使用 `订阅远行商人` 设置订阅,可用 `查看远行商人订阅` 确认当前订阅内容。
|
|
552
|
+
- 按关键词订阅时,商品名称是否能命中当前远行商人商品(按包含关系匹配)。
|
|
553
|
+
- 全部订阅模式(`订阅远行商人 全部`)在本轮商品为空时不会推送;每轮 `08:00 / 12:00 / 16:00 / 20:00` 只推一次,已推过的轮次不会重复。
|
|
542
554
|
- Bot 是否有向目标群聊发送消息的权限。
|
|
543
555
|
|
|
544
556
|
> 图片位置:远行商人订阅排查截图。建议插入 `docs/images/faq-merchant-subscription.png`。
|