koishi-plugin-wordle-game 4.2.1 → 4.3.0
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/CHANGELOG.md +4 -0
- package/DESIGN_SYSTEM.md +8 -8
- package/README.md +2 -2
- package/lib/index.js +121 -218
- package/lib/ux.d.ts +4 -22
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/DESIGN_SYSTEM.md
CHANGED
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
|
|
14
14
|
## 输出、交互与内容
|
|
15
15
|
|
|
16
|
-
1.
|
|
17
|
-
2.
|
|
16
|
+
1. 有渲染图时只发图片,不附同内容的文字,避免在群里重复刷屏;图片生成失败时才退回文字。插件不提供个人显示模式开关。
|
|
17
|
+
2. 每个插件的主指令都带描述,`help` 列表右侧不留空;主指令先于任何子指令注册(Koishi 会忽略已存在指令的描述)。文本回复不能把后续条目无提示地压掉;较长管理列表分页。
|
|
18
18
|
3. 裸输入必须符合词法、对局状态及参与条件。多个插件匹配时不执行,要求明确完整指令;完整指令继续可用。
|
|
19
19
|
4. 回复说明当前结果、未完成原因和可执行的下一步,不用管理员日志替代用户可用的反馈。退款、赔付与渲染失败不能伪装成功。
|
|
20
20
|
5. 破坏性清空需展示范围、不可撤销性和限时确认码。确认码限制到同一机器人、平台、用户与频道,使用后立即失效。
|
|
21
|
-
6.
|
|
21
|
+
6. 多轮输入等待 5 分钟,提问里写明可回复的内容与「取消」,不再追加计时说明。对局内的短窗口(如 21 点保险、投降)提供显式跳过,全员表态后立即进入下一阶段,而不是提供「延长」。
|
|
22
22
|
7. 货币发放先写入核对记录,入账结果不明确时保留待核对状态,不自动重发。管理员核对实际流水并按需人工补发后标记确认;确认操作自身不转账。
|
|
23
23
|
|
|
24
24
|
## 内容边界
|
|
@@ -44,7 +44,7 @@ node markdown-to-image-service/scripts/sync-design-system.mjs --check
|
|
|
44
44
|
|
|
45
45
|
官方色彩算法可在源仓库安装开发依赖后通过 `node scripts/build-material-colors.mjs` 重建,再同步消费者。
|
|
46
46
|
|
|
47
|
-
回归检查覆盖:24 个源色相的明暗角色对比度、奖牌前景、图表填充/轨道差异、浏览器/服务端 HCT
|
|
47
|
+
回归检查覆盖:24 个源色相的明暗角色对比度、奖牌前景、图表填充/轨道差异、浏览器/服务端 HCT 一致性、主指令描述、输入冲突、入账异常、清空确认和 Wordle 并发/渲染失败。工作区截图脚本为 `scripts/verify-rendering.ts`,需 Puppeteer Core 和可用 Chromium。
|
|
48
48
|
|
|
49
49
|
## 本轮改动对应关系
|
|
50
50
|
|
|
@@ -53,9 +53,9 @@ node markdown-to-image-service/scripts/sync-design-system.mjs --check
|
|
|
53
53
|
| 共享设计规范 | 官方 HCT、2025 动态颜色角色、共享字阶与间距、同步与哈希校验 |
|
|
54
54
|
| Markdown | M3 明暗主题;旧主题名按明暗迁移;代码高亮与 Mermaid 使用 M3 角色;长代码可换行 |
|
|
55
55
|
| message-counter / monetary-rank | M3 角色与共享图表字阶、HCT 头像配色、完整文字榜单;保留昵称截断 |
|
|
56
|
-
| Wordle | 替换复制的 NYT
|
|
57
|
-
| MCDLE |
|
|
56
|
+
| Wordle | 替换复制的 NYT 外观;状态符号与图例;明暗角色;异常释放并发锁;安全解析模式编号;裸词只在确定是猜测时回应 |
|
|
57
|
+
| MCDLE | 猜测按行排成一张表,方便逐项对照;单句页脚居中 |
|
|
58
58
|
| 2048 / ciyi | 数字与奖牌前景按实际对比度选色 |
|
|
59
|
-
| 斗牛 / 21 点 |
|
|
59
|
+
| 斗牛 / 21 点 | 付款核对记录、如实反馈退款失败、明确下注金额、可显式跳过的短窗口 |
|
|
60
60
|
| sentinel | 完整封印列表按每页 10 位展示 |
|
|
61
|
-
| 其余插件 |
|
|
61
|
+
| 其余插件 | 渲染失败退回文字、可取消输入与上下文反馈 |
|
package/README.md
CHANGED
|
@@ -34,6 +34,6 @@ yarn add koishi-plugin-wordle-game
|
|
|
34
34
|
|
|
35
35
|
## 显示与交互
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
有渲染图时只发图片,不再附带同内容的文字;图片生成失败时才退回文字。作品素材与感官测试的适用边界见 [设计系统](./DESIGN_SYSTEM.md)。
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
本次更新:无前缀猜测只接手确定有效的猜测(在词库中、未猜过),其余静默放行;汉兜提示色改为清晰的绿 / 琥珀,下划线对齐拼音;模式清单上下留白对称。 主指令在 help 列表里补回描述;去掉「.显示」显示模式指令,有图只发图、出图失败才退回文字;多轮输入不再追加计时说明。
|
package/lib/index.js
CHANGED
|
@@ -37,113 +37,11 @@ __export(src_exports, {
|
|
|
37
37
|
usage: () => usage
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(src_exports);
|
|
40
|
-
|
|
41
|
-
// src/ux.ts
|
|
42
|
-
var import_koishi = require("koishi");
|
|
43
|
-
var KEY = Symbol.for("araea.koishi.ux.v1");
|
|
44
|
-
function state(ctx) {
|
|
45
|
-
const root2 = ctx.root;
|
|
46
|
-
return root2[KEY] ??= { modes: /* @__PURE__ */ new Map(), owners: /* @__PURE__ */ new Set() };
|
|
47
|
-
}
|
|
48
|
-
__name(state, "state");
|
|
49
|
-
var userKey = /* @__PURE__ */ __name((session) => `${session.platform}:${session.selfId}:${session.userId}`, "userKey");
|
|
50
|
-
function usePresentation(ctx, command) {
|
|
51
|
-
const shared = state(ctx);
|
|
52
|
-
ctx.command(`${command}.显示 [mode:string]`, "选择图文或文字输出").action(({ session }, mode) => {
|
|
53
|
-
if (!mode) return `当前:${shared.modes.get(userKey(session)) ? "文字" : "图文"}。发送「${command}.显示 文字」或「${command}.显示 图文」。设置对本机器人各插件生效,重启后恢复图文。`;
|
|
54
|
-
if (!["文字", "图文"].includes(mode)) return "请选择「文字」或「图文」。";
|
|
55
|
-
shared.modes.set(userKey(session), mode === "文字");
|
|
56
|
-
return `已切换为${mode}输出。`;
|
|
57
|
-
});
|
|
58
|
-
return {
|
|
59
|
-
textOnly: /* @__PURE__ */ __name((session) => shared.modes.get(userKey(session)) === true, "textOnly"),
|
|
60
|
-
/** 图文模式只给图片;图片缺失或用户选了文字模式时才退回文字。 */
|
|
61
|
-
present(session, image, text) {
|
|
62
|
-
if (!image || shared.modes.get(userKey(session))) return text;
|
|
63
|
-
return import_koishi.h.normalize(image);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
__name(usePresentation, "usePresentation");
|
|
68
|
-
function registerDirectInput(ctx, name2, matches) {
|
|
69
|
-
const owner = { name: name2, matches };
|
|
70
|
-
state(ctx).owners.add(owner);
|
|
71
|
-
ctx.on("dispose", () => {
|
|
72
|
-
state(ctx).owners.delete(owner);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
__name(registerDirectInput, "registerDirectInput");
|
|
76
|
-
async function directInputConflict(ctx, session) {
|
|
77
|
-
if (session.event.user?.isBot) return true;
|
|
78
|
-
const owners = [];
|
|
79
|
-
for (const owner of state(ctx).owners) {
|
|
80
|
-
try {
|
|
81
|
-
if (await owner.matches(session)) owners.push(owner.name);
|
|
82
|
-
} catch {
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (owners.length < 2) return false;
|
|
86
|
-
await session.send(`这条消息同时适用于 ${owners.join("、")},尚未执行。请使用对应游戏的完整指令。`);
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
__name(directInputConflict, "directInputConflict");
|
|
90
|
-
async function promptInput(session, instruction) {
|
|
91
|
-
for (; ; ) {
|
|
92
|
-
await session.send(`${instruction}
|
|
93
|
-
请在 5 分钟内回复;发送「延长」重新计时,发送「取消」退出。`);
|
|
94
|
-
const input = await session.prompt(3e5);
|
|
95
|
-
if (input?.trim() === "延长") continue;
|
|
96
|
-
return input;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
__name(promptInput, "promptInput");
|
|
100
|
-
var IMAGE_TEXT_TYPE = "ux-image-text";
|
|
101
|
-
function imageText(text) {
|
|
102
|
-
return (0, import_koishi.h)(IMAGE_TEXT_TYPE, {}, import_koishi.h.normalize(text));
|
|
103
|
-
}
|
|
104
|
-
__name(imageText, "imageText");
|
|
105
|
-
function isImage(element) {
|
|
106
|
-
return element.type === "img" || element.type === "image";
|
|
107
|
-
}
|
|
108
|
-
__name(isImage, "isImage");
|
|
109
|
-
function isImageText(element) {
|
|
110
|
-
return element.type === IMAGE_TEXT_TYPE;
|
|
111
|
-
}
|
|
112
|
-
__name(isImageText, "isImageText");
|
|
113
|
-
function imagesOnly(content) {
|
|
114
|
-
const walk = /* @__PURE__ */ __name((elements) => elements.flatMap((element) => {
|
|
115
|
-
if (isImageText(element)) return [];
|
|
116
|
-
if (isImage(element) || !element.children.length) return [element];
|
|
117
|
-
return [(0, import_koishi.h)(element.type, element.attrs, walk(element.children))];
|
|
118
|
-
}), "walk");
|
|
119
|
-
return walk(import_koishi.h.normalize(content));
|
|
120
|
-
}
|
|
121
|
-
__name(imagesOnly, "imagesOnly");
|
|
122
|
-
function withoutImages(content) {
|
|
123
|
-
const walk = /* @__PURE__ */ __name((elements) => elements.flatMap((element) => {
|
|
124
|
-
if (isImage(element)) return [];
|
|
125
|
-
if (isImageText(element)) return walk(element.children);
|
|
126
|
-
if (element.children.length) return [(0, import_koishi.h)(element.type, element.attrs, walk(element.children))];
|
|
127
|
-
return [element];
|
|
128
|
-
}), "walk");
|
|
129
|
-
return walk(import_koishi.h.normalize(content));
|
|
130
|
-
}
|
|
131
|
-
__name(withoutImages, "withoutImages");
|
|
132
|
-
function choosePresentation(content, textOnly) {
|
|
133
|
-
return textOnly ? withoutImages(content) : imagesOnly(content);
|
|
134
|
-
}
|
|
135
|
-
__name(choosePresentation, "choosePresentation");
|
|
136
|
-
function isTextOnly(ctx, session) {
|
|
137
|
-
return state(ctx).modes.get(userKey(session)) === true;
|
|
138
|
-
}
|
|
139
|
-
__name(isTextOnly, "isTextOnly");
|
|
140
|
-
|
|
141
|
-
// src/index.ts
|
|
142
40
|
var fs6 = __toESM(require("fs"));
|
|
143
41
|
var path3 = __toESM(require("path"));
|
|
144
42
|
|
|
145
43
|
// src/config.ts
|
|
146
|
-
var
|
|
44
|
+
var import_koishi = require("koishi");
|
|
147
45
|
var usage = `## 使用
|
|
148
46
|
|
|
149
47
|
发送 \`wordle.开始\` 开局,之后直接发送猜测词即可。
|
|
@@ -167,44 +65,44 @@ var usage = `## 使用
|
|
|
167
65
|
模式包括经典、汉兜、词影、Numberle、Math、Lewdle 及其他词库。
|
|
168
66
|
|
|
169
67
|
可用选项:\`--hard\`、\`--uhard\`、\`--absurd\`、\`--challenge\`、\`--wordles\`、\`--free\`、\`--all\`。`;
|
|
170
|
-
var Config =
|
|
171
|
-
|
|
172
|
-
isDarkThemeEnabled:
|
|
173
|
-
isHighContrastThemeEnabled:
|
|
68
|
+
var Config = import_koishi.Schema.intersect([
|
|
69
|
+
import_koishi.Schema.object({
|
|
70
|
+
isDarkThemeEnabled: import_koishi.Schema.boolean().default(false).description(`使用黑暗主题。`),
|
|
71
|
+
isHighContrastThemeEnabled: import_koishi.Schema.boolean().default(false).description(`使用高对比度主题,为色觉障碍准备。`)
|
|
174
72
|
}).description("主题设置"),
|
|
175
|
-
|
|
176
|
-
compositeImagePageWidth:
|
|
177
|
-
compositeImagePageHeight:
|
|
178
|
-
maxSimultaneousGuesses:
|
|
179
|
-
defaultMaxLeaderboardEntries:
|
|
180
|
-
defaultWordLengthForGuessing:
|
|
73
|
+
import_koishi.Schema.object({
|
|
74
|
+
compositeImagePageWidth: import_koishi.Schema.number().min(1).default(800).description(`多词合成图的页面宽度(像素)。`),
|
|
75
|
+
compositeImagePageHeight: import_koishi.Schema.number().min(1).default(100).description(`多词合成图的页面高度(像素)。`),
|
|
76
|
+
maxSimultaneousGuesses: import_koishi.Schema.number().min(1).default(4).description(`同时猜测的单词数量上限。`),
|
|
77
|
+
defaultMaxLeaderboardEntries: import_koishi.Schema.number().min(0).default(10).description(`排行榜默认显示的人数。`),
|
|
78
|
+
defaultWordLengthForGuessing: import_koishi.Schema.number().min(1).default(5).description(`非经典模式下默认的猜测长度。`)
|
|
181
79
|
}).description("游戏设置"),
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
enableDirectInput:
|
|
185
|
-
isPreventUserDuplicateGuessInput:
|
|
186
|
-
shouldPromptWordLengthInput:
|
|
80
|
+
import_koishi.Schema.intersect([
|
|
81
|
+
import_koishi.Schema.object({
|
|
82
|
+
enableDirectInput: import_koishi.Schema.boolean().default(true).description(`对局中直接发送猜测词即可续猜,无需指令前缀。`),
|
|
83
|
+
isPreventUserDuplicateGuessInput: import_koishi.Schema.boolean().default(true).description(`拦截重复提交的猜测词。`),
|
|
84
|
+
shouldPromptWordLengthInput: import_koishi.Schema.boolean().default(true).description(
|
|
187
85
|
`引导式开局时,追问一次单词长度。关闭则直接用默认长度。`
|
|
188
86
|
),
|
|
189
|
-
shouldPromptForWordLengthOnNonClassicStart:
|
|
87
|
+
shouldPromptForWordLengthOnNonClassicStart: import_koishi.Schema.boolean().default(true).description(
|
|
190
88
|
`以非经典模式开局时,追问一次单词长度。关闭则直接用默认长度。`
|
|
191
89
|
)
|
|
192
90
|
}).description("游戏行为设置"),
|
|
193
|
-
|
|
194
|
-
enableWordGuessTimeLimit:
|
|
91
|
+
import_koishi.Schema.object({
|
|
92
|
+
enableWordGuessTimeLimit: import_koishi.Schema.boolean().default(false).description(`给每次作答加上时间限制。`)
|
|
195
93
|
}),
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
enableWordGuessTimeLimit:
|
|
199
|
-
wordGuessTimeLimitInSeconds:
|
|
94
|
+
import_koishi.Schema.union([
|
|
95
|
+
import_koishi.Schema.object({
|
|
96
|
+
enableWordGuessTimeLimit: import_koishi.Schema.const(true).required(),
|
|
97
|
+
wordGuessTimeLimitInSeconds: import_koishi.Schema.number().min(0).default(120).description(`每次作答的时间限制(秒)。`)
|
|
200
98
|
}),
|
|
201
|
-
|
|
99
|
+
import_koishi.Schema.object({})
|
|
202
100
|
]),
|
|
203
|
-
|
|
204
|
-
retractDelay:
|
|
101
|
+
import_koishi.Schema.object({
|
|
102
|
+
retractDelay: import_koishi.Schema.number().min(0).default(0).description(
|
|
205
103
|
`自动撤回延迟(秒),0 表示不撤回。`
|
|
206
104
|
),
|
|
207
|
-
imageType:
|
|
105
|
+
imageType: import_koishi.Schema.union(["png", "jpeg", "webp"]).default("png").description(`发送的图片格式。`)
|
|
208
106
|
})
|
|
209
107
|
])
|
|
210
108
|
]);
|
|
@@ -737,8 +635,8 @@ __name(processExtraGameRecords, "processExtraGameRecords");
|
|
|
737
635
|
async function sendMessage(g, session, message) {
|
|
738
636
|
const config = g.config;
|
|
739
637
|
const { bot, channelId } = session;
|
|
740
|
-
const [messageId] = await session.send(
|
|
741
|
-
if (
|
|
638
|
+
const [messageId] = await session.send(message);
|
|
639
|
+
if (config.retractDelay > 0 && messageId) {
|
|
742
640
|
const prevMessage = g.lastMessageInfo.get(channelId);
|
|
743
641
|
if (prevMessage) {
|
|
744
642
|
const timePassed = Date.now() - prevMessage.timestamp;
|
|
@@ -807,12 +705,47 @@ function register(g) {
|
|
|
807
705
|
return sendMessage(
|
|
808
706
|
g,
|
|
809
707
|
session,
|
|
810
|
-
"玩法:发送「wordle.开始」选择词库,再发送「wordle.猜 单词」。\n每次猜测会标记:✓ 字符与位置均正确;↔ 答案含该字符但位置不符;× 不包含(重复字符按数量判断)。\n「wordle.查询进度」查看已知线索;「wordle.拼音速查表」查看汉兜拼音;「wordle
|
|
708
|
+
"玩法:发送「wordle.开始」选择词库,再发送「wordle.猜 单词」。\n每次猜测会标记:✓ 字符与位置均正确;↔ 答案含该字符但位置不符;× 不包含(重复字符按数量判断)。\n「wordle.查询进度」查看已知线索;「wordle.拼音速查表」查看汉兜拼音;「wordle.结束」结束本局。"
|
|
811
709
|
);
|
|
812
710
|
});
|
|
813
711
|
}
|
|
814
712
|
__name(register, "register");
|
|
815
713
|
|
|
714
|
+
// src/ux.ts
|
|
715
|
+
var import_koishi2 = require("koishi");
|
|
716
|
+
var KEY = Symbol.for("araea.koishi.ux.v1");
|
|
717
|
+
function state(ctx) {
|
|
718
|
+
const root2 = ctx.root;
|
|
719
|
+
return root2[KEY] ??= { owners: /* @__PURE__ */ new Set() };
|
|
720
|
+
}
|
|
721
|
+
__name(state, "state");
|
|
722
|
+
function registerDirectInput(ctx, name2, matches) {
|
|
723
|
+
const owner = { name: name2, matches };
|
|
724
|
+
state(ctx).owners.add(owner);
|
|
725
|
+
ctx.on("dispose", () => {
|
|
726
|
+
state(ctx).owners.delete(owner);
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
__name(registerDirectInput, "registerDirectInput");
|
|
730
|
+
async function directInputConflict(ctx, session) {
|
|
731
|
+
if (session.event.user?.isBot) return true;
|
|
732
|
+
const owners = [];
|
|
733
|
+
for (const owner of state(ctx).owners) {
|
|
734
|
+
try {
|
|
735
|
+
if (await owner.matches(session)) owners.push(owner.name);
|
|
736
|
+
} catch {
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
if (owners.length < 2) return false;
|
|
740
|
+
await session.send(`这条消息同时适用于 ${owners.join("、")},尚未执行。请使用对应游戏的完整指令。`);
|
|
741
|
+
return true;
|
|
742
|
+
}
|
|
743
|
+
__name(directInputConflict, "directInputConflict");
|
|
744
|
+
function promptInput(session) {
|
|
745
|
+
return session.prompt(3e5);
|
|
746
|
+
}
|
|
747
|
+
__name(promptInput, "promptInput");
|
|
748
|
+
|
|
816
749
|
// src/services/renderer.ts
|
|
817
750
|
var import_cheerio = require("cheerio");
|
|
818
751
|
var import_url = require("url");
|
|
@@ -6168,16 +6101,20 @@ __name(resource, "resource");
|
|
|
6168
6101
|
// src/services/renderer.ts
|
|
6169
6102
|
var HUE = 142;
|
|
6170
6103
|
var imageDescriptions = /* @__PURE__ */ new WeakMap();
|
|
6171
|
-
function
|
|
6104
|
+
function imageText(buffer) {
|
|
6172
6105
|
return imageDescriptions.get(buffer) ?? "棋盘说明暂不可用,可发送「wordle.查询进度」。";
|
|
6173
6106
|
}
|
|
6174
|
-
__name(
|
|
6107
|
+
__name(imageText, "imageText");
|
|
6175
6108
|
function imageMessage(buffer, type) {
|
|
6176
|
-
const text =
|
|
6109
|
+
const text = imageText(buffer) ?? "图片内容请使用「wordle.查询进度」查询。";
|
|
6177
6110
|
if (!buffer.length) return (0, import_koishi3.h)("p", {}, import_koishi3.h.text(text));
|
|
6178
|
-
return
|
|
6111
|
+
return import_koishi3.h.image(buffer, type);
|
|
6179
6112
|
}
|
|
6180
6113
|
__name(imageMessage, "imageMessage");
|
|
6114
|
+
var HINT = {
|
|
6115
|
+
light: { ok: lch(40, 48, 142), mis: lch(46, 60, 62), okAlt: lch(46, 70, 50), misAlt: lch(42, 52, 260) },
|
|
6116
|
+
dark: { ok: lch(80, 56, 142), mis: lch(82, 60, 85), okAlt: lch(74, 62, 55), misAlt: lch(76, 40, 255) }
|
|
6117
|
+
};
|
|
6181
6118
|
var PANEL_WIDTH = 611;
|
|
6182
6119
|
async function capture(g, html, viewport, fileOrigin = false) {
|
|
6183
6120
|
const $ = (0, import_cheerio.load)(html);
|
|
@@ -6203,9 +6140,14 @@ async function capture(g, html, viewport, fileOrigin = false) {
|
|
|
6203
6140
|
await page.setViewport({ ...viewport, deviceScaleFactor: 1 });
|
|
6204
6141
|
if (fileOrigin) await page.goto((0, import_url.pathToFileURL)(resource("emptyHtml.html")).href);
|
|
6205
6142
|
await page.setContent(html, { waitUntil: "load" });
|
|
6206
|
-
const
|
|
6143
|
+
const dark = g.config.isDarkThemeEnabled;
|
|
6144
|
+
const c = scheme(HUE, dark);
|
|
6145
|
+
const hint = HINT[dark ? "dark" : "light"];
|
|
6207
6146
|
await page.addStyleTag({ content: `${baseline(c)} body{background:${c.surface}!important;color:${c.onSurface}!important} input{color:${c.onSurface};border-radius:12px}
|
|
6208
|
-
.text-ok{
|
|
6147
|
+
.text-ok,.text-mis{text-decoration-line:underline;text-decoration-thickness:1.5px;text-underline-offset:4px;text-decoration-skip-ink:none}
|
|
6148
|
+
.text-ok{color:${hint.ok}!important;text-decoration-style:double}.text-mis{color:${hint.mis}!important;text-decoration-style:dashed}
|
|
6149
|
+
.colorblind .text-ok{color:${hint.okAlt}!important}.colorblind .text-mis{color:${hint.misAlt}!important}
|
|
6150
|
+
.op35,.op80{opacity:1!important;color:${c.onSurfaceVariant}!important}
|
|
6209
6151
|
.bg-correct{background:${c.primary}!important;border-radius:12px}.fill-correct{fill:${c.primary}!important}.fill-white{fill:${c.onPrimary}!important}
|
|
6210
6152
|
.bg-base{background:${c.surface}!important} *{animation:none!important;transition:none!important}` });
|
|
6211
6153
|
buffer = await page.screenshot({ fullPage: true, type: g.config.imageType });
|
|
@@ -6378,11 +6320,12 @@ async function generatePanelImage(g, rows, isRanked = false) {
|
|
|
6378
6320
|
<style>
|
|
6379
6321
|
${baseline(s)}
|
|
6380
6322
|
${components()}
|
|
6381
|
-
body
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
}
|
|
6323
|
+
/* 留白放在外层容器上:截图时注入的基线样式会把 body 的内边距清零,上下就不对称了 */
|
|
6324
|
+
body { width: ${PANEL_WIDTH}px; background: var(--md-sys-color-surface); }
|
|
6325
|
+
.panel { padding: 24px; }
|
|
6326
|
+
/* 序号一位数、两位数时徽标同宽,名字才对得齐 */
|
|
6327
|
+
.m3-list-item .m3-badge { width: 36px; padding: 0; }
|
|
6328
|
+
.m3-list { margin: 0; }
|
|
6386
6329
|
/* 一屏里要放下十几行,行高比默认的列表项紧一档 */
|
|
6387
6330
|
.m3-list-item {
|
|
6388
6331
|
min-height: 48px;
|
|
@@ -6408,12 +6351,12 @@ async function generatePanelImage(g, rows, isRanked = false) {
|
|
|
6408
6351
|
</style>
|
|
6409
6352
|
</head>
|
|
6410
6353
|
<body>
|
|
6411
|
-
<ul class="m3-list">
|
|
6354
|
+
<main class="panel"><ul class="m3-list">
|
|
6412
6355
|
${items}
|
|
6413
|
-
</ul>
|
|
6356
|
+
</ul></main>
|
|
6414
6357
|
</body>
|
|
6415
6358
|
</html>`;
|
|
6416
|
-
return capture(g, html, { width: PANEL_WIDTH, height:
|
|
6359
|
+
return capture(g, html, { width: PANEL_WIDTH, height: 1 });
|
|
6417
6360
|
}
|
|
6418
6361
|
__name(generatePanelImage, "generatePanelImage");
|
|
6419
6362
|
async function renderPanel(g, rows, isRanked = false) {
|
|
@@ -17589,7 +17532,7 @@ function generateEmptyGridHtmlForHandle(rowNum, tileNum) {
|
|
|
17589
17532
|
__name(generateEmptyGridHtmlForHandle, "generateEmptyGridHtmlForHandle");
|
|
17590
17533
|
function generateImageTags(buffers) {
|
|
17591
17534
|
return buffers.map((buffer, index) => {
|
|
17592
|
-
const description = `棋盘 ${index + 1}:${
|
|
17535
|
+
const description = `棋盘 ${index + 1}:${imageText(buffer)}`;
|
|
17593
17536
|
if (!buffer.length) return `<p>${import_koishi4.h.escape(description)}</p>`;
|
|
17594
17537
|
return `<img src="data:image/png;base64,${buffer.toString("base64")}" alt="${import_koishi4.h.escape(description)}">`;
|
|
17595
17538
|
}).join("\n");
|
|
@@ -18429,75 +18372,36 @@ function register2(g) {
|
|
|
18429
18372
|
const idiomsList = g.data.idiomsList;
|
|
18430
18373
|
const pinyinData = g.data.pinyinData;
|
|
18431
18374
|
const equations = g.data.equations;
|
|
18375
|
+
async function directGuess(session) {
|
|
18376
|
+
if (!config.enableDirectInput || !session.channelId) return;
|
|
18377
|
+
const content = `${import_koishi5.h.select(session.content ?? "", "text")}`.trim();
|
|
18378
|
+
if (!content || !/^[\p{L}\d+*/=().-]+$/u.test(content)) return;
|
|
18379
|
+
const [gameInfo] = await ctx.database.get("wordle_game_records", { channelId: session.channelId });
|
|
18380
|
+
if (!gameInfo?.isStarted) return;
|
|
18381
|
+
const { gameMode } = gameInfo;
|
|
18382
|
+
const word = gameMode === "汉兜" || gameMode === "词影" ? content : content.toLowerCase();
|
|
18383
|
+
if (gameInfo.guessHistory?.includes(word)) return;
|
|
18384
|
+
if (gameMode === "汉兜" || gameMode === "词影") {
|
|
18385
|
+
if (!isFourCharacterIdiom(content)) return;
|
|
18386
|
+
const known = isIdiomInList(content, idiomsList) || gameMode === "汉兜" && pinyinData.some((item) => item.term === content);
|
|
18387
|
+
if (!known) return;
|
|
18388
|
+
if (gameMode === "词影" && !checkStrokesData(content, g.data.strokesData)) return;
|
|
18389
|
+
return content;
|
|
18390
|
+
}
|
|
18391
|
+
if (content.length !== gameInfo.guessWordLength) return;
|
|
18392
|
+
if (gameMode === "Numberle") return isNumericString(content) ? content : void 0;
|
|
18393
|
+
if (gameMode === "Math") return isMathEquationValid(content) ? content : void 0;
|
|
18394
|
+
if (!/^[a-zA-Z]+$/.test(content) || !findWord(word)) return;
|
|
18395
|
+
return content;
|
|
18396
|
+
}
|
|
18397
|
+
__name(directGuess, "directGuess");
|
|
18432
18398
|
registerDirectInput(ctx, "wordle-game", async (session) => {
|
|
18433
18399
|
if (!ctx.filter(session)) return false;
|
|
18434
|
-
|
|
18435
|
-
if (!config.enableDirectInput) {
|
|
18436
|
-
return false;
|
|
18437
|
-
}
|
|
18438
|
-
if (content) {
|
|
18439
|
-
content = `${import_koishi5.h.select(content, "text")}`.trim();
|
|
18440
|
-
}
|
|
18441
|
-
if (!channelId || !content || !/^[\p{L}\d+*/=().-]+$/u.test(content)) return false;
|
|
18442
|
-
const [gameInfo] = await ctx.database.get("wordle_game_records", { channelId });
|
|
18443
|
-
if (!gameInfo?.isStarted) {
|
|
18444
|
-
return false;
|
|
18445
|
-
}
|
|
18446
|
-
if (gameInfo.gameMode === "汉兜" || gameInfo.gameMode === "词影") {
|
|
18447
|
-
if (!isFourCharacterIdiom(content)) {
|
|
18448
|
-
return false;
|
|
18449
|
-
}
|
|
18450
|
-
} else if (gameInfo.gameMode === "Numberle") {
|
|
18451
|
-
if (!isNumericString(content)) {
|
|
18452
|
-
return false;
|
|
18453
|
-
}
|
|
18454
|
-
} else if (gameInfo.gameMode === "Math") {
|
|
18455
|
-
if (!isMathEquationValid(content)) {
|
|
18456
|
-
return false;
|
|
18457
|
-
}
|
|
18458
|
-
} else {
|
|
18459
|
-
if (!/^[a-zA-Z]+$/.test(content)) {
|
|
18460
|
-
return false;
|
|
18461
|
-
}
|
|
18462
|
-
}
|
|
18463
|
-
if (content.length !== gameInfo.guessWordLength) {
|
|
18464
|
-
return false;
|
|
18465
|
-
}
|
|
18466
|
-
return true;
|
|
18400
|
+
return Boolean(await directGuess(session));
|
|
18467
18401
|
});
|
|
18468
18402
|
ctx.middleware(async (session, next) => {
|
|
18469
|
-
|
|
18470
|
-
if (!
|
|
18471
|
-
return await next();
|
|
18472
|
-
}
|
|
18473
|
-
if (content) {
|
|
18474
|
-
content = `${import_koishi5.h.select(content, "text")}`.trim();
|
|
18475
|
-
}
|
|
18476
|
-
if (!channelId || !content || !/^[\p{L}\d+*/=().-]+$/u.test(content)) return next();
|
|
18477
|
-
const [gameInfo] = await ctx.database.get("wordle_game_records", { channelId });
|
|
18478
|
-
if (!gameInfo?.isStarted) {
|
|
18479
|
-
return await next();
|
|
18480
|
-
}
|
|
18481
|
-
if (gameInfo.gameMode === "汉兜" || gameInfo.gameMode === "词影") {
|
|
18482
|
-
if (!isFourCharacterIdiom(content)) {
|
|
18483
|
-
return await next();
|
|
18484
|
-
}
|
|
18485
|
-
} else if (gameInfo.gameMode === "Numberle") {
|
|
18486
|
-
if (!isNumericString(content)) {
|
|
18487
|
-
return await next();
|
|
18488
|
-
}
|
|
18489
|
-
} else if (gameInfo.gameMode === "Math") {
|
|
18490
|
-
if (!isMathEquationValid(content)) {
|
|
18491
|
-
return await next();
|
|
18492
|
-
}
|
|
18493
|
-
} else {
|
|
18494
|
-
if (!/^[a-zA-Z]+$/.test(content)) {
|
|
18495
|
-
return await next();
|
|
18496
|
-
}
|
|
18497
|
-
}
|
|
18498
|
-
if (content.length !== gameInfo.guessWordLength) {
|
|
18499
|
-
return await next();
|
|
18500
|
-
}
|
|
18403
|
+
const content = await directGuess(session);
|
|
18404
|
+
if (!content) return next();
|
|
18501
18405
|
if (await directInputConflict(ctx, session)) return;
|
|
18502
18406
|
await session.execute(`wordle.猜 ${content}`);
|
|
18503
18407
|
return;
|
|
@@ -18576,7 +18480,7 @@ ${generateGameEndMessage(gameInfo)}`}${processedResult}
|
|
|
18576
18480
|
${examPanel ?? examList}
|
|
18577
18481
|
发送序号或模式名即可开局,或发送「取消」。`
|
|
18578
18482
|
);
|
|
18579
|
-
const userInput = await promptInput(session
|
|
18483
|
+
const userInput = await promptInput(session);
|
|
18580
18484
|
if (!userInput)
|
|
18581
18485
|
return await sendMessage(
|
|
18582
18486
|
g,
|
|
@@ -18599,7 +18503,7 @@ ${examPanel ?? examList}
|
|
|
18599
18503
|
)}
|
|
18600
18504
|
发送一个长度即可开局,或发送「取消」。`
|
|
18601
18505
|
);
|
|
18602
|
-
const userInput2 = await promptInput(session
|
|
18506
|
+
const userInput2 = await promptInput(session);
|
|
18603
18507
|
if (!userInput2)
|
|
18604
18508
|
return await sendMessage(
|
|
18605
18509
|
g,
|
|
@@ -18779,7 +18683,7 @@ ${image}
|
|
|
18779
18683
|
)}
|
|
18780
18684
|
发送一个长度即可开局,或发送「取消」。`
|
|
18781
18685
|
);
|
|
18782
|
-
const userInput = await promptInput(session
|
|
18686
|
+
const userInput = await promptInput(session);
|
|
18783
18687
|
if (!userInput)
|
|
18784
18688
|
return await sendMessage(
|
|
18785
18689
|
g,
|
|
@@ -19059,7 +18963,7 @@ ${image}${tail}`
|
|
|
19059
18963
|
session,
|
|
19060
18964
|
`💡 发送一个猜测词,或发送「取消」。`
|
|
19061
18965
|
);
|
|
19062
|
-
const userInput = await promptInput(session
|
|
18966
|
+
const userInput = await promptInput(session);
|
|
19063
18967
|
if (!userInput) {
|
|
19064
18968
|
await setGuessRunningStatus(g, channelId, false);
|
|
19065
18969
|
return await sendMessage(
|
|
@@ -19400,7 +19304,7 @@ ${imageMessage(
|
|
|
19400
19304
|
发送「撤销」回到上一步,或发送「结束」收掉这一局。
|
|
19401
19305
|
没有等到有效输入时,按「撤销」处理。`
|
|
19402
19306
|
);
|
|
19403
|
-
let userInput = await promptInput(session
|
|
19307
|
+
let userInput = await promptInput(session);
|
|
19404
19308
|
const imageBuffer22 = await generateImage(
|
|
19405
19309
|
g,
|
|
19406
19310
|
styledHtml,
|
|
@@ -20460,7 +20364,6 @@ var inject = {
|
|
|
20460
20364
|
};
|
|
20461
20365
|
var name = "wordle-game";
|
|
20462
20366
|
async function apply(ctx, config) {
|
|
20463
|
-
const presentation = usePresentation(ctx, "wordle");
|
|
20464
20367
|
const logger = ctx.logger(`wordleGame`);
|
|
20465
20368
|
const wordleGameDirPath = path3.join(ctx.baseDir, "data", "wordleGame");
|
|
20466
20369
|
const idiomsFilePath = path3.join(__dirname, "assets", "汉兜", "idioms.json");
|
package/lib/ux.d.ts
CHANGED
|
@@ -3,29 +3,11 @@ type Owner = {
|
|
|
3
3
|
name: string;
|
|
4
4
|
matches: (session: Session) => boolean | Promise<boolean>;
|
|
5
5
|
};
|
|
6
|
-
/**
|
|
7
|
-
export declare function
|
|
8
|
-
textOnly: (session: Session) => boolean;
|
|
9
|
-
/** 图文模式只给图片;图片缺失或用户选了文字模式时才退回文字。 */
|
|
10
|
-
present(session: Session, image: h.Fragment | null | undefined, text: h.Fragment): h.Fragment;
|
|
11
|
-
};
|
|
6
|
+
/** 渲染图优先,只发图片;图片缺失时才退回等价文字。 */
|
|
7
|
+
export declare function present(image: h.Fragment | null | undefined, text: h.Fragment): h.Fragment;
|
|
12
8
|
/** Plugins register their active input grammar; overlapping messages are never executed. */
|
|
13
9
|
export declare function registerDirectInput(ctx: Context, name: string, matches: Owner['matches']): void;
|
|
14
10
|
export declare function directInputConflict(ctx: Context, session: Session): Promise<boolean>;
|
|
15
|
-
/**
|
|
16
|
-
export declare function promptInput(session: Session
|
|
17
|
-
export declare const IMAGE_FAILURE = "\u56FE\u7247\u6682\u65F6\u65E0\u6CD5\u751F\u6210\uFF0C\u5DF2\u4FDD\u7559\u6587\u5B57\u5185\u5BB9\u3002\u53EF\u4EE5\u7A0D\u540E\u91CD\u8BD5\uFF1B\u82E5\u6301\u7EED\u5931\u8D25\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u3002";
|
|
18
|
-
/**
|
|
19
|
-
* 渲染图的等价文字。图文模式随图片一起丢掉、文字模式展开成正文,
|
|
20
|
-
* 因此它永远不会原样发到聊天平台。
|
|
21
|
-
*/
|
|
22
|
-
export declare const IMAGE_TEXT_TYPE = "ux-image-text";
|
|
23
|
-
export declare function imageText(text: h.Fragment): h;
|
|
24
|
-
/** 图文模式:保留图片与普通文字,去掉图片的等价文字。 */
|
|
25
|
-
export declare function imagesOnly(content: h.Fragment): h[];
|
|
26
|
-
/** 文字模式:去掉图片,把等价文字展开成普通文本。 */
|
|
27
|
-
export declare function withoutImages(content: h.Fragment): h[];
|
|
28
|
-
/** 发送前的统一选择:文字模式去掉图片,图文模式去掉等价文字。 */
|
|
29
|
-
export declare function choosePresentation(content: h.Fragment, textOnly: boolean): h[];
|
|
30
|
-
export declare function isTextOnly(ctx: Context, session: Session): boolean;
|
|
11
|
+
/** 等待下一句回复。提问本身已经写明了可回复的内容与「取消」,这里不再追加说明。 */
|
|
12
|
+
export declare function promptInput(session: Session): Promise<string | undefined>;
|
|
31
13
|
export {};
|