koishi-plugin-wordle-game 2.8.1 → 2.9.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/README.md +2 -5
- package/lib/config.d.ts +1 -4
- package/lib/index.js +31 -679
- package/lib/services/database.d.ts +0 -6
- package/lib/services/leaderboard.d.ts +1 -1
- package/lib/services/network.d.ts +0 -5
- package/lib/types.d.ts +0 -9
- package/package.json +1 -3
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
yarn add koishi-plugin-wordle-game
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
在 Koishi 配置中启用,并提供
|
|
11
|
+
在 Koishi 配置中启用,并提供 database 与 puppeteer 服务。
|
|
12
12
|
|
|
13
13
|
## 指令
|
|
14
14
|
|
|
@@ -16,17 +16,14 @@ yarn add koishi-plugin-wordle-game
|
|
|
16
16
|
| --- | --- |
|
|
17
17
|
| `wordle.开始 [长度]` | 开始引导 |
|
|
18
18
|
| `wordle.开始.<模式> [长度]` | 指定模式开局 |
|
|
19
|
-
| `wordle.加入 [金币]` | 加入游戏 |
|
|
20
19
|
| `wordle.猜 <内容>` | 提交猜测 |
|
|
21
20
|
| `wordle.查询进度` | 查询当前游戏进度 |
|
|
22
|
-
| `wordle.退出` | 退出游戏 |
|
|
23
21
|
| `wordle.结束` | 结束游戏 |
|
|
24
22
|
| `wordle.排行榜 [人数]` | 查看排行榜 |
|
|
25
23
|
| `wordle.查询玩家记录 [@某人]` | 查询玩家记录 |
|
|
26
24
|
| `wordle.查单词 <词>` | 查单词引导 |
|
|
27
|
-
| `wordle.查成语 <成语>` |
|
|
25
|
+
| `wordle.查成语 <成语>` | 查询成语的拼音与解释(汉典) |
|
|
28
26
|
| `wordle.拼音速查表` | 查看拼音速查表 |
|
|
29
|
-
| `wordle.单词查找器 <索引>` | 用 WordFinder 查找匹配的单词 |
|
|
30
27
|
| `wordle.玩法介绍` | 游戏玩法介绍 |
|
|
31
28
|
|
|
32
29
|
模式包括经典、汉兜、词影、Numberle、Math、Lewdle 及其他词库。
|
package/lib/config.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { Schema } from "koishi";
|
|
2
|
-
export declare const usage = "## \u4F7F\u7528\n\n`wordle.\u5F00\u59CB` \u5F00\u5C40\uFF0C\u7136\u540E\u76F4\u63A5\u8F93\u5165\u731C\u6D4B\u8BCD\u3002\n\n## \u6307\u4EE4\n\n| \u6307\u4EE4 | \u8BF4\u660E |\n| --- | --- |\n| `wordle.\u5F00\u59CB [\u957F\u5EA6]` | \u5F00\u59CB\u5F15\u5BFC |\n| `wordle.\u5F00\u59CB.<\u6A21\u5F0F> [\u957F\u5EA6]` | \u6307\u5B9A\u6A21\u5F0F\u5F00\u5C40 |\n| `wordle.\
|
|
2
|
+
export declare const usage = "## \u4F7F\u7528\n\n`wordle.\u5F00\u59CB` \u5F00\u5C40\uFF0C\u7136\u540E\u76F4\u63A5\u8F93\u5165\u731C\u6D4B\u8BCD\u3002\n\n## \u6307\u4EE4\n\n| \u6307\u4EE4 | \u8BF4\u660E |\n| --- | --- |\n| `wordle.\u5F00\u59CB [\u957F\u5EA6]` | \u5F00\u59CB\u5F15\u5BFC |\n| `wordle.\u5F00\u59CB.<\u6A21\u5F0F> [\u957F\u5EA6]` | \u6307\u5B9A\u6A21\u5F0F\u5F00\u5C40 |\n| `wordle.\u731C <\u5185\u5BB9>` | \u63D0\u4EA4\u731C\u6D4B |\n| `wordle.\u67E5\u8BE2\u8FDB\u5EA6` | \u67E5\u8BE2\u5F53\u524D\u6E38\u620F\u8FDB\u5EA6 |\n| `wordle.\u7ED3\u675F` | \u7ED3\u675F\u6E38\u620F |\n| `wordle.\u6392\u884C\u699C [\u4EBA\u6570]` | \u67E5\u770B\u6392\u884C\u699C |\n| `wordle.\u67E5\u8BE2\u73A9\u5BB6\u8BB0\u5F55 [@\u67D0\u4EBA]` | \u67E5\u8BE2\u73A9\u5BB6\u8BB0\u5F55 |\n| `wordle.\u67E5\u5355\u8BCD <\u8BCD>` | \u67E5\u5355\u8BCD\u5F15\u5BFC |\n| `wordle.\u67E5\u6210\u8BED <\u6210\u8BED>` | \u67E5\u8BE2\u6210\u8BED\u7684\u62FC\u97F3\u4E0E\u89E3\u91CA\uFF08\u6C49\u5178\uFF09 |\n| `wordle.\u62FC\u97F3\u901F\u67E5\u8868` | \u67E5\u770B\u62FC\u97F3\u901F\u67E5\u8868 |\n| `wordle.\u73A9\u6CD5\u4ECB\u7ECD` | \u6E38\u620F\u73A9\u6CD5\u4ECB\u7ECD |\n\n\u6A21\u5F0F\u5305\u62EC\u7ECF\u5178\u3001\u6C49\u515C\u3001\u8BCD\u5F71\u3001Numberle\u3001Math\u3001Lewdle \u53CA\u5176\u4ED6\u8BCD\u5E93\u3002\n\n\u53EF\u7528\u9009\u9879\uFF1A`--hard`\u3001`--uhard`\u3001`--absurd`\u3001`--challenge`\u3001`--wordles`\u3001`--free`\u3001`--all`\u3002";
|
|
3
3
|
export interface Config {
|
|
4
4
|
isDarkThemeEnabled: boolean;
|
|
5
5
|
isHighContrastThemeEnabled: boolean;
|
|
6
6
|
defaultMaxLeaderboardEntries: number;
|
|
7
7
|
defaultWordLengthForGuessing: number;
|
|
8
|
-
maxInvestmentCurrency: number;
|
|
9
|
-
defaultRewardMultiplier: number;
|
|
10
8
|
maxSimultaneousGuesses: number;
|
|
11
9
|
compositeImagePageWidth: number;
|
|
12
10
|
compositeImagePageHeight: number;
|
|
13
|
-
allowNonPlayersToGuess: boolean;
|
|
14
11
|
enableWordGuessMiddleware: boolean;
|
|
15
12
|
shouldPromptWordLengthInput: boolean;
|
|
16
13
|
isPreventUserDuplicateGuessInput: boolean;
|
package/lib/index.js
CHANGED
|
@@ -52,17 +52,14 @@ var usage = `## 使用
|
|
|
52
52
|
| --- | --- |
|
|
53
53
|
| \`wordle.开始 [长度]\` | 开始引导 |
|
|
54
54
|
| \`wordle.开始.<模式> [长度]\` | 指定模式开局 |
|
|
55
|
-
| \`wordle.加入 [金币]\` | 加入游戏 |
|
|
56
55
|
| \`wordle.猜 <内容>\` | 提交猜测 |
|
|
57
56
|
| \`wordle.查询进度\` | 查询当前游戏进度 |
|
|
58
|
-
| \`wordle.退出\` | 退出游戏 |
|
|
59
57
|
| \`wordle.结束\` | 结束游戏 |
|
|
60
58
|
| \`wordle.排行榜 [人数]\` | 查看排行榜 |
|
|
61
59
|
| \`wordle.查询玩家记录 [@某人]\` | 查询玩家记录 |
|
|
62
60
|
| \`wordle.查单词 <词>\` | 查单词引导 |
|
|
63
|
-
| \`wordle.查成语 <成语>\` |
|
|
61
|
+
| \`wordle.查成语 <成语>\` | 查询成语的拼音与解释(汉典) |
|
|
64
62
|
| \`wordle.拼音速查表\` | 查看拼音速查表 |
|
|
65
|
-
| \`wordle.单词查找器 <索引>\` | 用 WordFinder 查找匹配的单词 |
|
|
66
63
|
| \`wordle.玩法介绍\` | 游戏玩法介绍 |
|
|
67
64
|
|
|
68
65
|
模式包括经典、汉兜、词影、Numberle、Math、Lewdle 及其他词库。
|
|
@@ -77,9 +74,7 @@ var Config = import_koishi.Schema.intersect([
|
|
|
77
74
|
compositeImagePageWidth: import_koishi.Schema.number().min(1).default(800).description(`合成图片页面宽度。`),
|
|
78
75
|
compositeImagePageHeight: import_koishi.Schema.number().min(1).default(100).description(`合成图片页面高度。`),
|
|
79
76
|
maxSimultaneousGuesses: import_koishi.Schema.number().min(1).default(4).description(`最多同时猜测单词的数量。`),
|
|
80
|
-
maxInvestmentCurrency: import_koishi.Schema.number().min(0).default(50).description(`加入游戏时可投入的最大货币数额。`),
|
|
81
77
|
defaultMaxLeaderboardEntries: import_koishi.Schema.number().min(0).default(10).description(`显示排行榜时默认的最大人数。`),
|
|
82
|
-
defaultRewardMultiplier: import_koishi.Schema.number().min(0).default(2).description(`猜单词经典模式赢了之后奖励的货币倍率。`),
|
|
83
78
|
defaultWordLengthForGuessing: import_koishi.Schema.number().min(1).default(5).description(`非经典游戏模式下,默认的猜单词长度。`)
|
|
84
79
|
}).description("游戏设置"),
|
|
85
80
|
import_koishi.Schema.intersect([
|
|
@@ -89,9 +84,6 @@ var Config = import_koishi.Schema.intersect([
|
|
|
89
84
|
shouldPromptWordLengthInput: import_koishi.Schema.boolean().default(true).description(
|
|
90
85
|
`是否在开始游戏引导中提示输入猜单词的长度,不开启则为默认长度。`
|
|
91
86
|
),
|
|
92
|
-
allowNonPlayersToGuess: import_koishi.Schema.boolean().default(true).description(
|
|
93
|
-
`是否允许未加入游戏的玩家进行猜单词的操作,开启后可以无需加入直接开始。`
|
|
94
|
-
),
|
|
95
87
|
shouldPromptForWordLengthOnNonClassicStart: import_koishi.Schema.boolean().default(true).description(
|
|
96
88
|
`是否在开始非经典模式时提示输入猜单词的长度,不开启则为默认长度。`
|
|
97
89
|
)
|
|
@@ -197,7 +189,6 @@ var exams = [
|
|
|
197
189
|
];
|
|
198
190
|
var rankType = [
|
|
199
191
|
"总",
|
|
200
|
-
"损益",
|
|
201
192
|
"猜出次数",
|
|
202
193
|
"经典",
|
|
203
194
|
"CET4",
|
|
@@ -448,14 +439,6 @@ async function getGameInfo2(g, channelId, wordleIndex) {
|
|
|
448
439
|
return gameRecord[0];
|
|
449
440
|
}
|
|
450
441
|
__name(getGameInfo2, "getGameInfo2");
|
|
451
|
-
async function getNumberOfPlayers(g, channelId) {
|
|
452
|
-
const playerRecords = await g.ctx.database.get(
|
|
453
|
-
"wordle_gaming_player_records",
|
|
454
|
-
{ channelId }
|
|
455
|
-
);
|
|
456
|
-
return playerRecords.length;
|
|
457
|
-
}
|
|
458
|
-
__name(getNumberOfPlayers, "getNumberOfPlayers");
|
|
459
442
|
async function isPlayerInGame(g, channelId, userId) {
|
|
460
443
|
const getPlayer = await g.ctx.database.get("wordle_gaming_player_records", {
|
|
461
444
|
channelId,
|
|
@@ -464,15 +447,6 @@ async function isPlayerInGame(g, channelId, userId) {
|
|
|
464
447
|
return getPlayer.length !== 0;
|
|
465
448
|
}
|
|
466
449
|
__name(isPlayerInGame, "isPlayerInGame");
|
|
467
|
-
async function getUserFromDatabase(g, platform, userId) {
|
|
468
|
-
return await g.ctx.database.getUser(platform, userId);
|
|
469
|
-
}
|
|
470
|
-
__name(getUserFromDatabase, "getUserFromDatabase");
|
|
471
|
-
async function getPlayerUid(g, platform, userId) {
|
|
472
|
-
const user = await getUserFromDatabase(g, platform, userId);
|
|
473
|
-
return user.id;
|
|
474
|
-
}
|
|
475
|
-
__name(getPlayerUid, "getPlayerUid");
|
|
476
450
|
async function updateNameInPlayerRecord(g, session, userId, username) {
|
|
477
451
|
const userRecord = await g.ctx.database.get("wordle_player_records", {
|
|
478
452
|
userId
|
|
@@ -527,76 +501,6 @@ async function endGame(g, channelId) {
|
|
|
527
501
|
]);
|
|
528
502
|
}
|
|
529
503
|
__name(endGame, "endGame");
|
|
530
|
-
async function deductMoney(g, channelId, platform) {
|
|
531
|
-
const getPlayers = await g.ctx.database.get("wordle_gaming_player_records", {
|
|
532
|
-
channelId
|
|
533
|
-
});
|
|
534
|
-
for (const thisGamingPlayer of getPlayers) {
|
|
535
|
-
const { userId, money } = thisGamingPlayer;
|
|
536
|
-
if (money === 0) {
|
|
537
|
-
continue;
|
|
538
|
-
}
|
|
539
|
-
const uid = await getPlayerUid(g, platform, userId);
|
|
540
|
-
const [userMonetary] = await g.ctx.database.get("monetary", { uid });
|
|
541
|
-
const value = userMonetary.value - money;
|
|
542
|
-
await g.ctx.database.set("monetary", { uid }, { value });
|
|
543
|
-
const [playerInfo] = await g.ctx.database.get("wordle_player_records", {
|
|
544
|
-
userId
|
|
545
|
-
});
|
|
546
|
-
await g.ctx.database.set(
|
|
547
|
-
"wordle_player_records",
|
|
548
|
-
{ userId },
|
|
549
|
-
{ moneyChange: playerInfo.moneyChange - money }
|
|
550
|
-
);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
__name(deductMoney, "deductMoney");
|
|
554
|
-
async function updateGamingPlayerRecords(g, channelId) {
|
|
555
|
-
const getPlayers = await g.ctx.database.get("wordle_gaming_player_records", {
|
|
556
|
-
channelId
|
|
557
|
-
});
|
|
558
|
-
for (const thisGamingPlayer of getPlayers) {
|
|
559
|
-
const { userId, money } = thisGamingPlayer;
|
|
560
|
-
if (money === 0) {
|
|
561
|
-
continue;
|
|
562
|
-
}
|
|
563
|
-
await g.ctx.database.set(
|
|
564
|
-
"wordle_gaming_player_records",
|
|
565
|
-
{ channelId, userId },
|
|
566
|
-
{ money: 0 }
|
|
567
|
-
);
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
__name(updateGamingPlayerRecords, "updateGamingPlayerRecords");
|
|
571
|
-
async function processNonZeroMoneyPlayers(g, channelId, platform) {
|
|
572
|
-
const getPlayers = await g.ctx.database.get("wordle_gaming_player_records", {
|
|
573
|
-
channelId
|
|
574
|
-
});
|
|
575
|
-
const settlementRecords = [];
|
|
576
|
-
for (const thisGamingPlayer of getPlayers) {
|
|
577
|
-
const { userId, money, username } = thisGamingPlayer;
|
|
578
|
-
if (money === 0) {
|
|
579
|
-
continue;
|
|
580
|
-
}
|
|
581
|
-
const uid = await getPlayerUid(g, platform, userId);
|
|
582
|
-
const rewardMultiplier = g.config.defaultRewardMultiplier;
|
|
583
|
-
const gainAmount = money * rewardMultiplier;
|
|
584
|
-
await g.ctx.monetary.gain(uid, gainAmount);
|
|
585
|
-
const [playerInfo] = await g.ctx.database.get("wordle_player_records", {
|
|
586
|
-
userId
|
|
587
|
-
});
|
|
588
|
-
const updatedMoneyChange = playerInfo.moneyChange + gainAmount;
|
|
589
|
-
await g.ctx.database.set(
|
|
590
|
-
"wordle_player_records",
|
|
591
|
-
{ userId },
|
|
592
|
-
{ moneyChange: updatedMoneyChange }
|
|
593
|
-
);
|
|
594
|
-
const settlementString = `【${username}】:【+${gainAmount}】`;
|
|
595
|
-
settlementRecords.push(settlementString);
|
|
596
|
-
}
|
|
597
|
-
return settlementRecords.join("\n");
|
|
598
|
-
}
|
|
599
|
-
__name(processNonZeroMoneyPlayers, "processNonZeroMoneyPlayers");
|
|
600
504
|
async function updatePlayerRecordsLose(g, channelId, gameInfo) {
|
|
601
505
|
const gamingPlayers = await g.ctx.database.get(
|
|
602
506
|
"wordle_gaming_player_records",
|
|
@@ -11450,37 +11354,6 @@ ${content}
|
|
|
11450
11354
|
}
|
|
11451
11355
|
}
|
|
11452
11356
|
__name(sendPostRequestForAI, "sendPostRequestForAI");
|
|
11453
|
-
async function fetchAndParseWords(g, url) {
|
|
11454
|
-
try {
|
|
11455
|
-
const html = await g.ctx.http.get(url, {
|
|
11456
|
-
responseType: "text",
|
|
11457
|
-
timeout: g.config.requestTimeout
|
|
11458
|
-
});
|
|
11459
|
-
const $ = (0, import_cheerio.load)(html);
|
|
11460
|
-
const wordGroups = $(".word-group");
|
|
11461
|
-
let finalResult = "";
|
|
11462
|
-
if (wordGroups.length === 0) {
|
|
11463
|
-
finalResult = "未找到。";
|
|
11464
|
-
} else {
|
|
11465
|
-
wordGroups.each((_, element) => {
|
|
11466
|
-
const title = $(element).find(".word-group__title").text();
|
|
11467
|
-
const words = $(element).find(".word-group__inner .word").map(
|
|
11468
|
-
(_2, el) => $(el).contents().filter(function() {
|
|
11469
|
-
return this.nodeType === 3;
|
|
11470
|
-
}).text().trim()
|
|
11471
|
-
).get();
|
|
11472
|
-
finalResult += `${title}:
|
|
11473
|
-
${words.join(", ")}
|
|
11474
|
-
|
|
11475
|
-
`;
|
|
11476
|
-
});
|
|
11477
|
-
}
|
|
11478
|
-
return finalResult;
|
|
11479
|
-
} catch (error) {
|
|
11480
|
-
g.logger.error("发生错误:", error);
|
|
11481
|
-
}
|
|
11482
|
-
}
|
|
11483
|
-
__name(fetchAndParseWords, "fetchAndParseWords");
|
|
11484
11357
|
async function fetchWordDefinitions(g, word) {
|
|
11485
11358
|
return g.ctx.http.post(
|
|
11486
11359
|
"https://wordword.org/api/words/get_by_word",
|
|
@@ -11507,43 +11380,25 @@ async function getIdiomInfo(g, idiom) {
|
|
|
11507
11380
|
const { idiomsList } = g.data;
|
|
11508
11381
|
try {
|
|
11509
11382
|
const html = await g.ctx.http.get(
|
|
11510
|
-
`https://
|
|
11383
|
+
`https://zdic.net/hans/${encodeURIComponent(idiom)}`,
|
|
11511
11384
|
{ responseType: "text", timeout: g.config.requestTimeout }
|
|
11512
11385
|
);
|
|
11513
11386
|
const $ = (0, import_cheerio.load)(html);
|
|
11514
|
-
const
|
|
11515
|
-
const
|
|
11516
|
-
|
|
11517
|
-
if (
|
|
11518
|
-
|
|
11387
|
+
const pinyin = $(".word-pronun-text").first().text().replace(/\s+/g, " ").trim();
|
|
11388
|
+
const pickTexts = /* @__PURE__ */ __name((selector) => $(selector).map((_, el) => $(el).text().trim()).get().filter((text) => text.length > 0), "pickTexts");
|
|
11389
|
+
let explanationParts = pickTexts("#xxjs .xxjs-item__def");
|
|
11390
|
+
if (explanationParts.length === 0) {
|
|
11391
|
+
const idiomDefinition = $("#cy .idiom-entry__line").filter(
|
|
11392
|
+
(_, el) => $(el).find(".idiom-entry__label").text().trim() === "解释"
|
|
11393
|
+
).find(".idiom-entry__text").text().trim();
|
|
11394
|
+
if (idiomDefinition) {
|
|
11395
|
+
explanationParts = [idiomDefinition];
|
|
11396
|
+
}
|
|
11519
11397
|
}
|
|
11520
|
-
if (
|
|
11521
|
-
|
|
11522
|
-
idiom,
|
|
11523
|
-
pinyin,
|
|
11524
|
-
explanation: "【解释】" + explanation
|
|
11525
|
-
};
|
|
11526
|
-
idiomsList.push(newIdiom);
|
|
11527
|
-
writeIdiomsToFile(g, g.paths.idiomsKoishi, idiomsList);
|
|
11398
|
+
if (explanationParts.length === 0) {
|
|
11399
|
+
explanationParts = pickTexts("#gyjs .gy-sense__def");
|
|
11528
11400
|
}
|
|
11529
|
-
|
|
11530
|
-
} catch (error) {
|
|
11531
|
-
return { pinyin: "未找到拼音", explanation: "未找到解释" };
|
|
11532
|
-
}
|
|
11533
|
-
}
|
|
11534
|
-
__name(getIdiomInfo, "getIdiomInfo");
|
|
11535
|
-
async function getIdiomInfo2(g, idiom) {
|
|
11536
|
-
const { idiomsList } = g.data;
|
|
11537
|
-
try {
|
|
11538
|
-
const html = await g.ctx.http.get(
|
|
11539
|
-
`https://www.zdic.net/hans/${encodeURIComponent(idiom)}`,
|
|
11540
|
-
{ responseType: "text", timeout: g.config.requestTimeout }
|
|
11541
|
-
);
|
|
11542
|
-
const $ = (0, import_cheerio.load)(html);
|
|
11543
|
-
const pinyin = $(".ciif.noi.zisong .dicpy").first().text().replace(/\s+/g, " ").trim();
|
|
11544
|
-
const cyjsDiv = $("#cyjs");
|
|
11545
|
-
cyjsDiv.find("h3").remove();
|
|
11546
|
-
const explanation = cyjsDiv.find("p").map((_, p) => $(p).text()).get().join("\n");
|
|
11401
|
+
const explanation = explanationParts.join("\n");
|
|
11547
11402
|
if (!pinyin || !explanation) {
|
|
11548
11403
|
throw new Error("找不到拼音或解释。");
|
|
11549
11404
|
}
|
|
@@ -11554,14 +11409,14 @@ async function getIdiomInfo2(g, idiom) {
|
|
|
11554
11409
|
explanation
|
|
11555
11410
|
};
|
|
11556
11411
|
idiomsList.push(newIdiom);
|
|
11557
|
-
writeIdiomsToFile(g, g.paths.
|
|
11412
|
+
writeIdiomsToFile(g, g.paths.idiomsKoishi, idiomsList);
|
|
11558
11413
|
}
|
|
11559
11414
|
return { pinyin, explanation };
|
|
11560
11415
|
} catch (error) {
|
|
11561
11416
|
return { pinyin: "未找到拼音", explanation: "未找到解释" };
|
|
11562
11417
|
}
|
|
11563
11418
|
}
|
|
11564
|
-
__name(
|
|
11419
|
+
__name(getIdiomInfo, "getIdiomInfo");
|
|
11565
11420
|
async function getSelectedIdiom(g, randomIdiom) {
|
|
11566
11421
|
const { idiomsList } = g.data;
|
|
11567
11422
|
let selectedIdiom = void 0;
|
|
@@ -14014,198 +13869,6 @@ function register2(g) {
|
|
|
14014
13869
|
await session.execute(`wordle.猜 ${content}`);
|
|
14015
13870
|
return;
|
|
14016
13871
|
});
|
|
14017
|
-
ctx.command("wordle.加入 [money:number]", "加入游戏").action(async ({ session }, money = 0) => {
|
|
14018
|
-
let { channelId, userId, username, user } = session;
|
|
14019
|
-
username = await getSessionUserName(g, session);
|
|
14020
|
-
await updateNameInPlayerRecord(g, session, userId, username);
|
|
14021
|
-
let gameInfo = await getGameInfo(g, channelId);
|
|
14022
|
-
const isInGame = await isPlayerInGame(g, channelId, userId);
|
|
14023
|
-
if (gameInfo.isStarted) {
|
|
14024
|
-
if (!isInGame) {
|
|
14025
|
-
return await sendMessage(
|
|
14026
|
-
g,
|
|
14027
|
-
session,
|
|
14028
|
-
`⚠️ 游戏已经开始,无法中途加入。`
|
|
14029
|
-
);
|
|
14030
|
-
} else {
|
|
14031
|
-
const wordlesNum = gameInfo.wordlesNum;
|
|
14032
|
-
const isAbsurd = gameInfo.isAbsurd;
|
|
14033
|
-
let imageBuffers = [];
|
|
14034
|
-
let imageBuffer = Buffer.from("initial value", "utf-8");
|
|
14035
|
-
for (let wordleIndex = 1; wordleIndex < wordlesNum + 1; wordleIndex++) {
|
|
14036
|
-
if (wordleIndex > 1) {
|
|
14037
|
-
gameInfo = await getGameInfo2(g, channelId, wordleIndex);
|
|
14038
|
-
}
|
|
14039
|
-
if (gameInfo.gameMode === "汉兜") {
|
|
14040
|
-
const emptyGridHtml = generateEmptyGridHtmlForHandle(1, 4);
|
|
14041
|
-
imageBuffer = await generateImageForHandle(
|
|
14042
|
-
g,
|
|
14043
|
-
`${gameInfo.wordGuessHtmlCache}
|
|
14044
|
-
${emptyGridHtml}`
|
|
14045
|
-
);
|
|
14046
|
-
} else {
|
|
14047
|
-
const emptyGridHtml = isAbsurd ? generateEmptyGridHtml(1, gameInfo.guessWordLength) : generateEmptyGridHtml(
|
|
14048
|
-
gameInfo.remainingGuessesCount,
|
|
14049
|
-
gameInfo.guessWordLength
|
|
14050
|
-
);
|
|
14051
|
-
const styledHtml = generateStyledHtml(
|
|
14052
|
-
gameInfo.guessWordLength + 1
|
|
14053
|
-
);
|
|
14054
|
-
imageBuffer = await generateImage(
|
|
14055
|
-
g,
|
|
14056
|
-
styledHtml,
|
|
14057
|
-
`${gameInfo.wordGuessHtmlCache}
|
|
14058
|
-
${emptyGridHtml}`
|
|
14059
|
-
);
|
|
14060
|
-
}
|
|
14061
|
-
imageBuffers.push(imageBuffer);
|
|
14062
|
-
}
|
|
14063
|
-
if (wordlesNum > 1) {
|
|
14064
|
-
const htmlImgString = generateImageTags(imageBuffers);
|
|
14065
|
-
imageBuffer = await generateWordlesImage(g, htmlImgString);
|
|
14066
|
-
}
|
|
14067
|
-
return await sendMessage(
|
|
14068
|
-
g,
|
|
14069
|
-
session,
|
|
14070
|
-
`⚠️ 你已经在游戏中。
|
|
14071
|
-
${import_koishi3.h.image(
|
|
14072
|
-
imageBuffer,
|
|
14073
|
-
`image/${config.imageType}`
|
|
14074
|
-
)}`
|
|
14075
|
-
);
|
|
14076
|
-
}
|
|
14077
|
-
}
|
|
14078
|
-
if (typeof money !== "number" || money < 0) {
|
|
14079
|
-
return await sendMessage(
|
|
14080
|
-
g,
|
|
14081
|
-
session,
|
|
14082
|
-
`⚠️ 请输入不小于 0 的投入金额。`
|
|
14083
|
-
);
|
|
14084
|
-
}
|
|
14085
|
-
if (money > config.maxInvestmentCurrency) {
|
|
14086
|
-
return await sendMessage(
|
|
14087
|
-
g,
|
|
14088
|
-
session,
|
|
14089
|
-
`⚠️ 投入金额不能超过 ${config.maxInvestmentCurrency}。`
|
|
14090
|
-
);
|
|
14091
|
-
}
|
|
14092
|
-
const uid = user.id;
|
|
14093
|
-
let getUserMonetary = await ctx.database.get("monetary", { uid });
|
|
14094
|
-
if (getUserMonetary.length === 0) {
|
|
14095
|
-
await ctx.database.create("monetary", {
|
|
14096
|
-
uid,
|
|
14097
|
-
value: 0,
|
|
14098
|
-
currency: "default"
|
|
14099
|
-
});
|
|
14100
|
-
getUserMonetary = await ctx.database.get("monetary", { uid });
|
|
14101
|
-
}
|
|
14102
|
-
const userMonetary = getUserMonetary[0];
|
|
14103
|
-
const numberOfPlayers = await getNumberOfPlayers(g, channelId);
|
|
14104
|
-
if (isInGame) {
|
|
14105
|
-
if (userMonetary.value >= money) {
|
|
14106
|
-
await ctx.database.set(
|
|
14107
|
-
"wordle_gaming_player_records",
|
|
14108
|
-
{ channelId, userId },
|
|
14109
|
-
{ money }
|
|
14110
|
-
);
|
|
14111
|
-
return await sendMessage(
|
|
14112
|
-
g,
|
|
14113
|
-
session,
|
|
14114
|
-
`✅ 投入已改为 ${money}。当前玩家:${numberOfPlayers} 人。`
|
|
14115
|
-
);
|
|
14116
|
-
} else {
|
|
14117
|
-
await ctx.database.set(
|
|
14118
|
-
"wordle_gaming_player_records",
|
|
14119
|
-
{ channelId, userId },
|
|
14120
|
-
{ money: userMonetary.value }
|
|
14121
|
-
);
|
|
14122
|
-
return await sendMessage(
|
|
14123
|
-
g,
|
|
14124
|
-
session,
|
|
14125
|
-
`⚠️ 余额不足,投入已修正为 ${userMonetary.value}。当前玩家:${numberOfPlayers} 人。`
|
|
14126
|
-
);
|
|
14127
|
-
}
|
|
14128
|
-
}
|
|
14129
|
-
if (money === 0) {
|
|
14130
|
-
await ctx.database.create("wordle_gaming_player_records", {
|
|
14131
|
-
channelId,
|
|
14132
|
-
userId,
|
|
14133
|
-
username,
|
|
14134
|
-
money
|
|
14135
|
-
});
|
|
14136
|
-
if (userMonetary.value > 0) {
|
|
14137
|
-
return await sendMessage(
|
|
14138
|
-
g,
|
|
14139
|
-
session,
|
|
14140
|
-
`✅ 加入成功。经典模式可带上金额再加入一次以投入。
|
|
14141
|
-
最大投入:${config.maxInvestmentCurrency},倍率:${config.defaultRewardMultiplier}。当前玩家:${numberOfPlayers + 1} 人。`
|
|
14142
|
-
);
|
|
14143
|
-
} else {
|
|
14144
|
-
return await sendMessage(
|
|
14145
|
-
g,
|
|
14146
|
-
session,
|
|
14147
|
-
`✅ 加入成功。当前玩家:${numberOfPlayers + 1} 人。`
|
|
14148
|
-
);
|
|
14149
|
-
}
|
|
14150
|
-
} else {
|
|
14151
|
-
if (userMonetary.value >= money) {
|
|
14152
|
-
await ctx.database.create("wordle_gaming_player_records", {
|
|
14153
|
-
channelId,
|
|
14154
|
-
userId,
|
|
14155
|
-
username,
|
|
14156
|
-
money
|
|
14157
|
-
});
|
|
14158
|
-
return await sendMessage(
|
|
14159
|
-
g,
|
|
14160
|
-
session,
|
|
14161
|
-
`✅ 加入成功,投入 ${money}。倍率:${config.defaultRewardMultiplier}。当前玩家:${numberOfPlayers + 1} 人。`
|
|
14162
|
-
);
|
|
14163
|
-
} else {
|
|
14164
|
-
await ctx.database.create("wordle_gaming_player_records", {
|
|
14165
|
-
channelId,
|
|
14166
|
-
userId,
|
|
14167
|
-
username,
|
|
14168
|
-
money: userMonetary.value
|
|
14169
|
-
});
|
|
14170
|
-
return await sendMessage(
|
|
14171
|
-
g,
|
|
14172
|
-
session,
|
|
14173
|
-
`⚠️ 余额不足,投入已修正为 ${userMonetary.value}。当前玩家:${numberOfPlayers + 1} 人。`
|
|
14174
|
-
);
|
|
14175
|
-
}
|
|
14176
|
-
}
|
|
14177
|
-
});
|
|
14178
|
-
ctx.command("wordle.退出", "退出游戏").action(async ({ session }) => {
|
|
14179
|
-
let { channelId, userId, username } = session;
|
|
14180
|
-
username = await getSessionUserName(g, session);
|
|
14181
|
-
await updateNameInPlayerRecord(g, session, userId, username);
|
|
14182
|
-
const gameInfo = await getGameInfo(g, channelId);
|
|
14183
|
-
if (gameInfo.isStarted) {
|
|
14184
|
-
return await sendMessage(
|
|
14185
|
-
g,
|
|
14186
|
-
session,
|
|
14187
|
-
`⚠️ 游戏已经开始,无法进行此操作。`
|
|
14188
|
-
);
|
|
14189
|
-
}
|
|
14190
|
-
const isInGame = await isPlayerInGame(g, channelId, userId);
|
|
14191
|
-
if (!isInGame) {
|
|
14192
|
-
return await sendMessage(
|
|
14193
|
-
g,
|
|
14194
|
-
session,
|
|
14195
|
-
`⚠️ 你还没有加入游戏。`
|
|
14196
|
-
);
|
|
14197
|
-
}
|
|
14198
|
-
await ctx.database.remove("wordle_gaming_player_records", {
|
|
14199
|
-
channelId,
|
|
14200
|
-
userId
|
|
14201
|
-
});
|
|
14202
|
-
const numberOfPlayers = await getNumberOfPlayers(g, channelId);
|
|
14203
|
-
return await sendMessage(
|
|
14204
|
-
g,
|
|
14205
|
-
session,
|
|
14206
|
-
`✅ 已退出。剩余玩家:${numberOfPlayers} 人。`
|
|
14207
|
-
);
|
|
14208
|
-
});
|
|
14209
13872
|
ctx.command("wordle.结束", "结束游戏").action(async ({ session }) => {
|
|
14210
13873
|
let { channelId, userId, username, timestamp } = session;
|
|
14211
13874
|
username = await getSessionUserName(g, session);
|
|
@@ -14315,7 +13978,7 @@ ${exams.map((exam, index) => `${index + 1}. ${exam}`).join("\n")}
|
|
|
14315
13978
|
ctx.command("wordle.开始.经典", "开始经典猜单词游戏").option("hard", "--hard 困难模式", { fallback: false }).option("ultraHardMode", "--uhard 超困难模式", { fallback: false }).option("absurd", "--absurd 变态模式", { fallback: false }).option("challenge", "--challenge 变态挑战模式", { fallback: false }).option("wordles", "--wordles <value:number> 同时猜测多个单词", {
|
|
14316
13979
|
fallback: 1
|
|
14317
13980
|
}).action(async ({ session, options }) => {
|
|
14318
|
-
let { channelId, userId, username,
|
|
13981
|
+
let { channelId, userId, username, timestamp } = session;
|
|
14319
13982
|
username = await getSessionUserName(g, session);
|
|
14320
13983
|
await updateNameInPlayerRecord(g, session, userId, username);
|
|
14321
13984
|
if (typeof options.wordles !== "number" || options.wordles < 1 || options.wordles > config.maxSimultaneousGuesses) {
|
|
@@ -14333,18 +13996,6 @@ ${exams.map((exam, index) => `${index + 1}. ${exam}`).join("\n")}
|
|
|
14333
13996
|
`⚠️ 游戏已经开始了。`
|
|
14334
13997
|
);
|
|
14335
13998
|
}
|
|
14336
|
-
const numberOfPlayers = await getNumberOfPlayers(g, channelId);
|
|
14337
|
-
if (numberOfPlayers < 1 && !config.allowNonPlayersToGuess) {
|
|
14338
|
-
return await sendMessage(
|
|
14339
|
-
g,
|
|
14340
|
-
session,
|
|
14341
|
-
`没人玩的说...
|
|
14342
|
-
且当前配置为:
|
|
14343
|
-
【不允许没有加入的玩家猜单词】
|
|
14344
|
-
请先加入游戏吧~`
|
|
14345
|
-
);
|
|
14346
|
-
}
|
|
14347
|
-
await deductMoney(g, channelId, platform);
|
|
14348
13999
|
const selectedWords = [];
|
|
14349
14000
|
const randomWord = lowerCaseWordArray_default[Math.floor(Math.random() * lowerCaseWordArray_default.length)].toLowerCase();
|
|
14350
14001
|
selectedWords.push(randomWord);
|
|
@@ -14459,7 +14110,7 @@ ${image}`;
|
|
|
14459
14110
|
}).option("hard", "--hard 困难模式", { fallback: false }).option("ultraHardMode", "--uhard 超困难模式", { fallback: false }).option("absurd", "--absurd 变态模式", { fallback: false }).option("challenge", "--challenge 变态挑战模式", { fallback: false }).option("wordles", "--wordles <value:number> 同时猜测多个", {
|
|
14460
14111
|
fallback: 1
|
|
14461
14112
|
}).action(async ({ session, options }, guessWordLength) => {
|
|
14462
|
-
let { channelId, userId, username, timestamp
|
|
14113
|
+
let { channelId, userId, username, timestamp } = session;
|
|
14463
14114
|
username = await getSessionUserName(g, session);
|
|
14464
14115
|
await updateNameInPlayerRecord(g, session, userId, username);
|
|
14465
14116
|
if (!guessWordLength) {
|
|
@@ -14509,22 +14160,6 @@ ${exam} 长度可选值范围:${getValidGuessWordLengthRange(
|
|
|
14509
14160
|
`⚠️ 游戏已经开始了。`
|
|
14510
14161
|
);
|
|
14511
14162
|
}
|
|
14512
|
-
const numberOfPlayers = await getNumberOfPlayers(g, channelId);
|
|
14513
|
-
if (numberOfPlayers < 1 && !config.allowNonPlayersToGuess) {
|
|
14514
|
-
return await sendMessage(
|
|
14515
|
-
g,
|
|
14516
|
-
session,
|
|
14517
|
-
`没人玩的说...
|
|
14518
|
-
且当前配置为:
|
|
14519
|
-
【不允许没有加入的玩家猜测】
|
|
14520
|
-
先加入游戏吧~`
|
|
14521
|
-
);
|
|
14522
|
-
}
|
|
14523
|
-
if (exam !== "汉兜") {
|
|
14524
|
-
await updateGamingPlayerRecords(g, channelId);
|
|
14525
|
-
} else {
|
|
14526
|
-
await deductMoney(g, channelId, platform);
|
|
14527
|
-
}
|
|
14528
14163
|
const selectedWords = [];
|
|
14529
14164
|
let randomWord = "";
|
|
14530
14165
|
let translation = "";
|
|
@@ -14732,7 +14367,7 @@ ${image}`
|
|
|
14732
14367
|
});
|
|
14733
14368
|
});
|
|
14734
14369
|
ctx.command("wordle.猜 [inputWord:text]", "做出一次猜测").option("random", "-r 随机", { fallback: false }).action(async ({ session, options }, inputWord) => {
|
|
14735
|
-
let { channelId, userId, username,
|
|
14370
|
+
let { channelId, userId, username, timestamp } = session;
|
|
14736
14371
|
let gameInfo = await getGameInfo(g, channelId);
|
|
14737
14372
|
inputWord = inputWord?.trim();
|
|
14738
14373
|
if (gameInfo.isRunning === true) {
|
|
@@ -14793,21 +14428,11 @@ ${image}`
|
|
|
14793
14428
|
}
|
|
14794
14429
|
const isInGame = await isPlayerInGame(g, channelId, userId);
|
|
14795
14430
|
if (!isInGame) {
|
|
14796
|
-
|
|
14797
|
-
|
|
14798
|
-
|
|
14799
|
-
|
|
14800
|
-
|
|
14801
|
-
`⚠️ 你还没有加入游戏,无法猜测。`
|
|
14802
|
-
);
|
|
14803
|
-
} else {
|
|
14804
|
-
await ctx.database.create("wordle_gaming_player_records", {
|
|
14805
|
-
channelId,
|
|
14806
|
-
userId,
|
|
14807
|
-
username,
|
|
14808
|
-
money: 0
|
|
14809
|
-
});
|
|
14810
|
-
}
|
|
14431
|
+
await ctx.database.create("wordle_gaming_player_records", {
|
|
14432
|
+
channelId,
|
|
14433
|
+
userId,
|
|
14434
|
+
username
|
|
14435
|
+
});
|
|
14811
14436
|
}
|
|
14812
14437
|
let {
|
|
14813
14438
|
correctLetters,
|
|
@@ -15300,14 +14925,6 @@ ${emptyGridHtml}`
|
|
|
15300
14925
|
}
|
|
15301
14926
|
gameInfo = await getGameInfo(g, channelId);
|
|
15302
14927
|
if (isWin) {
|
|
15303
|
-
let finalSettlementString = "";
|
|
15304
|
-
if (gameInfo.gameMode === "经典" || gameInfo.gameMode === "汉兜") {
|
|
15305
|
-
finalSettlementString = await processNonZeroMoneyPlayers(
|
|
15306
|
-
g,
|
|
15307
|
-
channelId,
|
|
15308
|
-
platform
|
|
15309
|
-
);
|
|
15310
|
-
}
|
|
15311
14928
|
await updatePlayerRecordsWin(g, channelId, gameInfo);
|
|
15312
14929
|
const [playerRecord] = await ctx.database.get("wordle_player_records", {
|
|
15313
14930
|
userId
|
|
@@ -15358,14 +14975,11 @@ ${await processExtraGameRecords(g, channelId)}` : "";
|
|
|
15358
14975
|
timestamp
|
|
15359
14976
|
);
|
|
15360
14977
|
const imageType = config.imageType;
|
|
15361
|
-
const settlementResult = finalSettlementString === "" ? "" : `最终结算结果如下:
|
|
15362
|
-
${finalSettlementString}`;
|
|
15363
14978
|
const message = `
|
|
15364
14979
|
太棒了,你猜出来了!
|
|
15365
14980
|
${gameDuration}
|
|
15366
14981
|
${import_koishi3.h.image(imageBuffer, `image/${imageType}`)}
|
|
15367
14982
|
${generateGameEndMessage(gameInfo)}${processedResult}
|
|
15368
|
-
${settlementResult}
|
|
15369
14983
|
`;
|
|
15370
14984
|
await sendMessage(
|
|
15371
14985
|
g,
|
|
@@ -15571,46 +15185,7 @@ ${serializedDefinitions ? serializedDefinitions : `- 该单词定义暂未收录
|
|
|
15571
15185
|
);
|
|
15572
15186
|
});
|
|
15573
15187
|
});
|
|
15574
|
-
ctx.command("wordle.查成语 [targetIdiom:text]", "
|
|
15575
|
-
if (!targetIdiom && session.event.message.quote && session.event.message.quote.content) {
|
|
15576
|
-
if (isFourCharacterIdiom(session.event.message.quote.content.trim())) {
|
|
15577
|
-
targetIdiom = session.event.message.quote.content.trim();
|
|
15578
|
-
}
|
|
15579
|
-
}
|
|
15580
|
-
let { userId, username } = session;
|
|
15581
|
-
username = await getSessionUserName(g, session);
|
|
15582
|
-
await updateNameInPlayerRecord(g, session, userId, username);
|
|
15583
|
-
const availableDictionaryArray = ["百度汉语", "汉典"];
|
|
15584
|
-
await sendMessage(
|
|
15585
|
-
g,
|
|
15586
|
-
session,
|
|
15587
|
-
`当前可用词库如下:
|
|
15588
|
-
${availableDictionaryArray.map((dictionary, index) => `${index + 1}. ${dictionary}`).join("\n")}
|
|
15589
|
-
请输入序号或词库名。`
|
|
15590
|
-
);
|
|
15591
|
-
const userInput = await session.prompt();
|
|
15592
|
-
if (!userInput)
|
|
15593
|
-
return await sendMessage(
|
|
15594
|
-
g,
|
|
15595
|
-
session,
|
|
15596
|
-
`⚠️ 输入无效或超时。`
|
|
15597
|
-
);
|
|
15598
|
-
const selectedDictionary = isNaN(parseInt(userInput)) ? userInput.trim() : availableDictionaryArray[parseInt(userInput) - 1];
|
|
15599
|
-
if (availableDictionaryArray.includes(selectedDictionary)) {
|
|
15600
|
-
const command = `wordle.查成语.${selectedDictionary}${targetIdiom ? ` ${targetIdiom}` : ""}`;
|
|
15601
|
-
return await session.execute(command);
|
|
15602
|
-
} else {
|
|
15603
|
-
return await sendMessage(
|
|
15604
|
-
g,
|
|
15605
|
-
session,
|
|
15606
|
-
`⚠️ 输入无效,请重新输入。`
|
|
15607
|
-
);
|
|
15608
|
-
}
|
|
15609
|
-
});
|
|
15610
|
-
ctx.command(
|
|
15611
|
-
"wordle.查成语.百度汉语 [targetIdiom:text]",
|
|
15612
|
-
"在百度汉语中查找成语解释"
|
|
15613
|
-
).action(async ({ session }, targetIdiom) => {
|
|
15188
|
+
ctx.command("wordle.查成语 [targetIdiom:text]", "查询成语的拼音与解释(汉典)").action(async ({ session }, targetIdiom) => {
|
|
15614
15189
|
if (!targetIdiom && session.event.message.quote && session.event.message.quote.content) {
|
|
15615
15190
|
if (isFourCharacterIdiom(session.event.message.quote.content.trim())) {
|
|
15616
15191
|
targetIdiom = session.event.message.quote.content.trim();
|
|
@@ -15649,63 +15224,6 @@ ${availableDictionaryArray.map((dictionary, index) => `${index + 1}. ${dictionar
|
|
|
15649
15224
|
);
|
|
15650
15225
|
}
|
|
15651
15226
|
const idiomInfo = await getIdiomInfo(g, targetIdiom);
|
|
15652
|
-
if (idiomInfo.pinyin === "未找到拼音") {
|
|
15653
|
-
return await sendMessage(
|
|
15654
|
-
g,
|
|
15655
|
-
session,
|
|
15656
|
-
`⚠️ 未在百度汉语中找到该成语。`
|
|
15657
|
-
);
|
|
15658
|
-
}
|
|
15659
|
-
return await sendMessage(
|
|
15660
|
-
g,
|
|
15661
|
-
session,
|
|
15662
|
-
`【成语】${targetIdiom}
|
|
15663
|
-
【拼音】${idiomInfo.pinyin}
|
|
15664
|
-
【解释】${idiomInfo.explanation}`
|
|
15665
|
-
);
|
|
15666
|
-
});
|
|
15667
|
-
ctx.command(
|
|
15668
|
-
"wordle.查成语.汉典 [targetIdiom:text]",
|
|
15669
|
-
"在汉典中查找成语解释"
|
|
15670
|
-
).action(async ({ session }, targetIdiom) => {
|
|
15671
|
-
if (!targetIdiom && session.event.message.quote && session.event.message.quote.content) {
|
|
15672
|
-
if (isFourCharacterIdiom(session.event.message.quote.content.trim())) {
|
|
15673
|
-
targetIdiom = session.event.message.quote.content.trim();
|
|
15674
|
-
}
|
|
15675
|
-
}
|
|
15676
|
-
let { userId, username } = session;
|
|
15677
|
-
username = await getSessionUserName(g, session);
|
|
15678
|
-
await updateNameInPlayerRecord(g, session, userId, username);
|
|
15679
|
-
targetIdiom = targetIdiom?.trim();
|
|
15680
|
-
if (!targetIdiom) {
|
|
15681
|
-
await sendMessage(
|
|
15682
|
-
g,
|
|
15683
|
-
session,
|
|
15684
|
-
`⚠️ 请输入待查找的成语,或发送「取消」。`
|
|
15685
|
-
);
|
|
15686
|
-
const userInput = await session.prompt();
|
|
15687
|
-
if (!userInput)
|
|
15688
|
-
return await sendMessage(
|
|
15689
|
-
g,
|
|
15690
|
-
session,
|
|
15691
|
-
`⚠️ 输入无效或超时。`
|
|
15692
|
-
);
|
|
15693
|
-
if (userInput === "取消")
|
|
15694
|
-
return await sendMessage(
|
|
15695
|
-
g,
|
|
15696
|
-
session,
|
|
15697
|
-
`✅ 已取消查找成语。`
|
|
15698
|
-
);
|
|
15699
|
-
targetIdiom = userInput.trim();
|
|
15700
|
-
}
|
|
15701
|
-
if (!isFourCharacterIdiom(targetIdiom)) {
|
|
15702
|
-
return await sendMessage(
|
|
15703
|
-
g,
|
|
15704
|
-
session,
|
|
15705
|
-
`⚠️ 请输入四字词语。`
|
|
15706
|
-
);
|
|
15707
|
-
}
|
|
15708
|
-
const idiomInfo = await getIdiomInfo2(g, targetIdiom);
|
|
15709
15227
|
if (idiomInfo.pinyin === "未找到拼音") {
|
|
15710
15228
|
return await sendMessage(
|
|
15711
15229
|
g,
|
|
@@ -15718,144 +15236,9 @@ ${availableDictionaryArray.map((dictionary, index) => `${index + 1}. ${dictionar
|
|
|
15718
15236
|
session,
|
|
15719
15237
|
`【成语】${targetIdiom}
|
|
15720
15238
|
【拼音】${idiomInfo.pinyin}
|
|
15721
|
-
|
|
15239
|
+
【解释】${idiomInfo.explanation}`
|
|
15722
15240
|
);
|
|
15723
15241
|
});
|
|
15724
|
-
ctx.command(
|
|
15725
|
-
"wordle.单词查找器 [wordleIndexs:text]",
|
|
15726
|
-
"使用WordFinder查找匹配的单词"
|
|
15727
|
-
).option("auto", "-a 自动查找(根据游戏进程)", { fallback: false }).option("wordLength", "-l <length> 指定要搜索的单词长度", {
|
|
15728
|
-
fallback: void 0
|
|
15729
|
-
}).option(
|
|
15730
|
-
"wordWithThreeWildcards",
|
|
15731
|
-
"-w <word> 搜索带有最多三个通配符字符的单词",
|
|
15732
|
-
{ fallback: void 0 }
|
|
15733
|
-
).option("containingLetters", "-c <letters> 搜索包含特定字母组合的单词", {
|
|
15734
|
-
fallback: void 0
|
|
15735
|
-
}).option(
|
|
15736
|
-
"containingTheseLetters",
|
|
15737
|
-
"--ct <letters> 搜索只包含指定字母的单词",
|
|
15738
|
-
{ fallback: void 0 }
|
|
15739
|
-
).option("withoutTheseLetters", "--wt <letters> 搜索不包含特定字母的单词", {
|
|
15740
|
-
fallback: void 0
|
|
15741
|
-
}).option(
|
|
15742
|
-
"startingWithTheseLetters",
|
|
15743
|
-
"--sw <letters> 搜索以特定字母开头的单词",
|
|
15744
|
-
{ fallback: void 0 }
|
|
15745
|
-
).option(
|
|
15746
|
-
"endingWithTheseLetters",
|
|
15747
|
-
"--ew <letters> 搜索以特定字母结尾的单词",
|
|
15748
|
-
{ fallback: void 0 }
|
|
15749
|
-
).action(async ({ session, options }, wordleIndexs) => {
|
|
15750
|
-
let { channelId, username, userId } = session;
|
|
15751
|
-
username = await getSessionUserName(g, session);
|
|
15752
|
-
await updateNameInPlayerRecord(g, session, userId, username);
|
|
15753
|
-
let {
|
|
15754
|
-
auto,
|
|
15755
|
-
wordLength,
|
|
15756
|
-
wordWithThreeWildcards,
|
|
15757
|
-
containingLetters,
|
|
15758
|
-
containingTheseLetters,
|
|
15759
|
-
withoutTheseLetters,
|
|
15760
|
-
startingWithTheseLetters,
|
|
15761
|
-
endingWithTheseLetters
|
|
15762
|
-
} = options;
|
|
15763
|
-
if (auto) {
|
|
15764
|
-
const gameInfo = await getGameInfo(g, channelId);
|
|
15765
|
-
const {
|
|
15766
|
-
isStarted,
|
|
15767
|
-
wordlesNum,
|
|
15768
|
-
guessWordLength,
|
|
15769
|
-
absentLetters,
|
|
15770
|
-
presentLetters,
|
|
15771
|
-
gameMode
|
|
15772
|
-
} = gameInfo;
|
|
15773
|
-
if (!isStarted) {
|
|
15774
|
-
return await sendMessage(
|
|
15775
|
-
g,
|
|
15776
|
-
session,
|
|
15777
|
-
`⚠️ 未检测到游戏进度,无法使用自动查找。`
|
|
15778
|
-
);
|
|
15779
|
-
}
|
|
15780
|
-
if (gameMode === "汉兜") {
|
|
15781
|
-
return await sendMessage(
|
|
15782
|
-
g,
|
|
15783
|
-
session,
|
|
15784
|
-
`⚠️ 单词查找器不能用于四字词语。`
|
|
15785
|
-
);
|
|
15786
|
-
}
|
|
15787
|
-
if (wordlesNum === 1) {
|
|
15788
|
-
await session.execute(
|
|
15789
|
-
`wordle.单词查找器 -l ${guessWordLength} --ct ${presentLetters} --wt ${absentLetters}`
|
|
15790
|
-
);
|
|
15791
|
-
} else {
|
|
15792
|
-
let userInput = "";
|
|
15793
|
-
if (!wordleIndexs) {
|
|
15794
|
-
await sendMessage(
|
|
15795
|
-
g,
|
|
15796
|
-
session,
|
|
15797
|
-
`当前进度数量:${wordlesNum}。请输入待查询序号(从左到右,可用空格隔开,例如:1 2)。`
|
|
15798
|
-
);
|
|
15799
|
-
userInput = await session.prompt();
|
|
15800
|
-
if (!userInput)
|
|
15801
|
-
return await sendMessage(
|
|
15802
|
-
g,
|
|
15803
|
-
session,
|
|
15804
|
-
`⚠️ 输入无效或超时。`
|
|
15805
|
-
);
|
|
15806
|
-
} else {
|
|
15807
|
-
userInput = wordleIndexs;
|
|
15808
|
-
}
|
|
15809
|
-
const stringArray = userInput.split(" ");
|
|
15810
|
-
for (const element of stringArray) {
|
|
15811
|
-
if (!isNaN(Number(element))) {
|
|
15812
|
-
const index = parseInt(element);
|
|
15813
|
-
if (index > 0 && index <= wordlesNum) {
|
|
15814
|
-
if (index === 1) {
|
|
15815
|
-
await session.execute(
|
|
15816
|
-
`wordle.单词查找器 -l ${guessWordLength} --ct ${presentLetters} --wt ${absentLetters}`
|
|
15817
|
-
);
|
|
15818
|
-
} else {
|
|
15819
|
-
const gameInfo2 = await getGameInfo2(g, channelId, index);
|
|
15820
|
-
const { guessWordLength: guessWordLength2, absentLetters: absentLetters2, presentLetters: presentLetters2 } = gameInfo2;
|
|
15821
|
-
await session.execute(
|
|
15822
|
-
`wordle.单词查找器 -l ${guessWordLength2} --ct ${presentLetters2} --wt ${absentLetters2}`
|
|
15823
|
-
);
|
|
15824
|
-
}
|
|
15825
|
-
} else {
|
|
15826
|
-
await session.send(
|
|
15827
|
-
`序号 ${index} 超出范围(1~${wordlesNum})。`
|
|
15828
|
-
);
|
|
15829
|
-
continue;
|
|
15830
|
-
}
|
|
15831
|
-
} else {
|
|
15832
|
-
continue;
|
|
15833
|
-
}
|
|
15834
|
-
}
|
|
15835
|
-
}
|
|
15836
|
-
}
|
|
15837
|
-
if (auto) {
|
|
15838
|
-
return;
|
|
15839
|
-
}
|
|
15840
|
-
const noOptionsSpecified = !wordLength && !wordWithThreeWildcards && !containingLetters && !containingTheseLetters && !withoutTheseLetters && !startingWithTheseLetters && !endingWithTheseLetters;
|
|
15841
|
-
if (noOptionsSpecified) {
|
|
15842
|
-
const chineseTutorial = "欢迎使用单词查找器!\n你可以使用以下选项来搜索匹配的单词:\n- 使用 -a 自动查找(根据游戏进程)\n- 使用 -l <length> 指定要搜索的单词长度\n- 使用 -w <word> 搜索带有最多三个通配符字符的单词\n- 使用 -c <letters> 搜索包含特定字母组合的单词\n- 使用 --ct <letters> 搜索只包含指定字母的单词\n- 使用 --wt <letters> 搜索不包含特定字母的单词\n- 使用 --sw <letters> 搜索以特定字母开头的单词\n- 使用 --ew <letters> 搜索以特定字母结尾的单词";
|
|
15843
|
-
return await sendMessage(g, session, chineseTutorial);
|
|
15844
|
-
}
|
|
15845
|
-
const params = {
|
|
15846
|
-
wordLength: wordLength ? `${wordLength}-letter-words` : "",
|
|
15847
|
-
wordWithThreeWildcards: wordWithThreeWildcards ? `out-of-${wordWithThreeWildcards}` : "",
|
|
15848
|
-
containingLetters: containingLetters ? `containing-${containingLetters}` : "",
|
|
15849
|
-
containingTheseLetters: containingTheseLetters ? `with-${containingTheseLetters}` : "",
|
|
15850
|
-
withoutTheseLetters: withoutTheseLetters ? `without-${withoutTheseLetters}` : "",
|
|
15851
|
-
startingWithTheseLetters: startingWithTheseLetters ? `starting-with-${startingWithTheseLetters}` : "",
|
|
15852
|
-
endingWithTheseLetters: endingWithTheseLetters ? `ending-with-${endingWithTheseLetters}` : ""
|
|
15853
|
-
};
|
|
15854
|
-
const queryParams = Object.values(params).filter((param) => param).join("-");
|
|
15855
|
-
const url = `https://wordword.org/search/${queryParams}`;
|
|
15856
|
-
const result = await fetchAndParseWords(g, url);
|
|
15857
|
-
return await sendMessage(g, session, `${result}`);
|
|
15858
|
-
});
|
|
15859
15242
|
ctx.command("wordle.查询玩家记录 [targetUser:text]", "查询玩家记录").action(async ({ session }, targetUser) => {
|
|
15860
15243
|
let { userId, username } = session;
|
|
15861
15244
|
const originalUserId = userId;
|
|
@@ -15890,19 +15273,11 @@ ${idiomInfo.explanation}`
|
|
|
15890
15273
|
`⚠️ 被查询对象没有任何游戏记录。`
|
|
15891
15274
|
);
|
|
15892
15275
|
}
|
|
15893
|
-
const {
|
|
15894
|
-
win,
|
|
15895
|
-
lose,
|
|
15896
|
-
moneyChange,
|
|
15897
|
-
wordGuessCount,
|
|
15898
|
-
stats,
|
|
15899
|
-
fastestGuessTime
|
|
15900
|
-
} = targetUserRecord[0];
|
|
15276
|
+
const { win, lose, wordGuessCount, stats, fastestGuessTime } = targetUserRecord[0];
|
|
15901
15277
|
const queryInfo = `📋 查询对象:${targetUserRecord[0].username}
|
|
15902
15278
|
猜出次数:${wordGuessCount} 次
|
|
15903
15279
|
总胜场:${win} 次
|
|
15904
15280
|
总输场:${lose} 次
|
|
15905
|
-
损益为:${moneyChange} 点
|
|
15906
15281
|
详细统计信息如下:
|
|
15907
15282
|
${generateStatsInfo(stats, fastestGuessTime)}
|
|
15908
15283
|
`;
|
|
@@ -16154,7 +15529,7 @@ async function getCiyingSuccessCountLeaderboardForCiying(g, session, wordlesNum,
|
|
|
16154
15529
|
return await sendMessage(g, session, result);
|
|
16155
15530
|
}
|
|
16156
15531
|
__name(getCiyingSuccessCountLeaderboardForCiying, "getCiyingSuccessCountLeaderboardForCiying");
|
|
16157
|
-
async function getLeaderboard(g, session,
|
|
15532
|
+
async function getLeaderboard(g, session, sortField, title, number) {
|
|
16158
15533
|
const getPlayers = await g.ctx.database.get(
|
|
16159
15534
|
"wordle_player_records",
|
|
16160
15535
|
{}
|
|
@@ -16166,7 +15541,7 @@ async function getLeaderboard(g, session, type, sortField, title, number) {
|
|
|
16166
15541
|
let result = `${title}:
|
|
16167
15542
|
`;
|
|
16168
15543
|
topPlayers.forEach((player, index) => {
|
|
16169
|
-
result += `${index + 1}. ${player.username}:${player[sortField]}
|
|
15544
|
+
result += `${index + 1}. ${player.username}:${player[sortField]} 次
|
|
16170
15545
|
`;
|
|
16171
15546
|
});
|
|
16172
15547
|
return await sendMessage(g, session, result);
|
|
@@ -16280,24 +15655,6 @@ ${rankType3.map((type2, index) => `${index + 1}. ${type2}`).join("\n")}
|
|
|
16280
15655
|
}
|
|
16281
15656
|
);
|
|
16282
15657
|
});
|
|
16283
|
-
ctx.command("wordle.排行榜.损益 [number:number]", "查看玩家损益排行榜").action(
|
|
16284
|
-
async ({ session }, number = config.defaultMaxLeaderboardEntries) => {
|
|
16285
|
-
let { username, userId } = session;
|
|
16286
|
-
username = await getSessionUserName(g, session);
|
|
16287
|
-
await updateNameInPlayerRecord(g, session, userId, username);
|
|
16288
|
-
if (typeof number !== "number" || isNaN(number) || number < 0) {
|
|
16289
|
-
return "⚠️ 请输入不小于 0 的数字作为排行榜人数。";
|
|
16290
|
-
}
|
|
16291
|
-
return await getLeaderboard(
|
|
16292
|
-
g,
|
|
16293
|
-
session,
|
|
16294
|
-
"moneyChange",
|
|
16295
|
-
"moneyChange",
|
|
16296
|
-
"玩家损益排行榜",
|
|
16297
|
-
number
|
|
16298
|
-
);
|
|
16299
|
-
}
|
|
16300
|
-
);
|
|
16301
15658
|
ctx.command(
|
|
16302
15659
|
"wordle.排行榜.猜出次数 [number:number]",
|
|
16303
15660
|
"查看玩家猜出次数排行榜"
|
|
@@ -16313,7 +15670,6 @@ ${rankType3.map((type2, index) => `${index + 1}. ${type2}`).join("\n")}
|
|
|
16313
15670
|
g,
|
|
16314
15671
|
session,
|
|
16315
15672
|
"wordGuessCount",
|
|
16316
|
-
"wordGuessCount",
|
|
16317
15673
|
"玩家猜出次数排行榜",
|
|
16318
15674
|
number
|
|
16319
15675
|
);
|
|
@@ -16334,7 +15690,6 @@ ${rankType3.map((type2, index) => `${index + 1}. ${type2}`).join("\n")}
|
|
|
16334
15690
|
g,
|
|
16335
15691
|
session,
|
|
16336
15692
|
"win",
|
|
16337
|
-
"win",
|
|
16338
15693
|
"玩家总胜场排行榜",
|
|
16339
15694
|
number
|
|
16340
15695
|
);
|
|
@@ -16355,7 +15710,6 @@ ${rankType3.map((type2, index) => `${index + 1}. ${type2}`).join("\n")}
|
|
|
16355
15710
|
g,
|
|
16356
15711
|
session,
|
|
16357
15712
|
"lose",
|
|
16358
|
-
"lose",
|
|
16359
15713
|
"查看玩家总输场排行榜",
|
|
16360
15714
|
number
|
|
16361
15715
|
);
|
|
@@ -16519,7 +15873,7 @@ __name(register5, "register");
|
|
|
16519
15873
|
|
|
16520
15874
|
// src/index.ts
|
|
16521
15875
|
var inject = {
|
|
16522
|
-
required: ["
|
|
15876
|
+
required: ["database", "puppeteer"]
|
|
16523
15877
|
};
|
|
16524
15878
|
var name = "wordle-game";
|
|
16525
15879
|
async function apply(ctx, config) {
|
|
@@ -16642,7 +15996,6 @@ async function apply(ctx, config) {
|
|
|
16642
15996
|
id: "unsigned",
|
|
16643
15997
|
channelId: "string",
|
|
16644
15998
|
username: "string",
|
|
16645
|
-
money: "unsigned",
|
|
16646
15999
|
userId: "string"
|
|
16647
16000
|
},
|
|
16648
16001
|
{
|
|
@@ -16658,7 +16011,6 @@ async function apply(ctx, config) {
|
|
|
16658
16011
|
userId: "string",
|
|
16659
16012
|
lose: "unsigned",
|
|
16660
16013
|
win: "unsigned",
|
|
16661
|
-
moneyChange: "double",
|
|
16662
16014
|
wordGuessCount: "unsigned",
|
|
16663
16015
|
stats: { type: "json", initial: initialStats },
|
|
16664
16016
|
fastestGuessTime: { type: "json", initial: initialFastestGuessTime },
|
|
@@ -2,16 +2,10 @@ import type { GameContext } from "../context";
|
|
|
2
2
|
import type { ExtraGameRecord, GameRecord } from "../types";
|
|
3
3
|
export declare function getGameInfo(g: GameContext, channelId: string): Promise<GameRecord>;
|
|
4
4
|
export declare function getGameInfo2(g: GameContext, channelId: string, wordleIndex: number): Promise<ExtraGameRecord>;
|
|
5
|
-
export declare function getNumberOfPlayers(g: GameContext, channelId: string): Promise<number>;
|
|
6
5
|
export declare function isPlayerInGame(g: GameContext, channelId: string, userId: string): Promise<boolean>;
|
|
7
|
-
export declare function getUserFromDatabase(g: GameContext, platform: string, userId: string): Promise<import("minato").FlatPick<import("koishi").User, import("minato").FlatKeys<import("koishi").User>>>;
|
|
8
|
-
export declare function getPlayerUid(g: GameContext, platform: string, userId: string): Promise<number>;
|
|
9
6
|
export declare function updateNameInPlayerRecord(g: GameContext, session: any, userId: string, username: string): Promise<void>;
|
|
10
7
|
export declare function setGuessRunningStatus(g: GameContext, channelId: string, isRunning: boolean): Promise<void>;
|
|
11
8
|
export declare function endGame(g: GameContext, channelId: string): Promise<void>;
|
|
12
|
-
export declare function deductMoney(g: GameContext, channelId: string, platform: string): Promise<void>;
|
|
13
|
-
export declare function updateGamingPlayerRecords(g: GameContext, channelId: string): Promise<void>;
|
|
14
|
-
export declare function processNonZeroMoneyPlayers(g: GameContext, channelId: string, platform: string): Promise<string>;
|
|
15
9
|
export declare function updatePlayerRecordsLose(g: GameContext, channelId: string, gameInfo: GameRecord): Promise<void>;
|
|
16
10
|
export declare function updatePlayerRecordsWin(g: GameContext, channelId: string, gameInfo: GameRecord): Promise<void>;
|
|
17
11
|
export declare function processExtraGameInfos(g: GameContext, channelId: string): Promise<string>;
|
|
@@ -3,6 +3,6 @@ export declare function getWinCountLeaderboardForCiying(g: GameContext, session:
|
|
|
3
3
|
export declare function getLoseCountLeaderboardForCiying(g: GameContext, session: any, wordlesNum: number, title: string, number: number, isHardMode: boolean): Promise<void>;
|
|
4
4
|
export declare function getFastestGuessTimeLeaderboardForCiying(g: GameContext, session: any, wordlesNum: number, title: string, number: number, isHardMode: boolean): Promise<void>;
|
|
5
5
|
export declare function getCiyingSuccessCountLeaderboardForCiying(g: GameContext, session: any, wordlesNum: number, sortField: string, title: string, number: number, isHardMode: boolean): Promise<void>;
|
|
6
|
-
export declare function getLeaderboard(g: GameContext, session: any,
|
|
6
|
+
export declare function getLeaderboard(g: GameContext, session: any, sortField: string, title: string, number: number): Promise<void>;
|
|
7
7
|
export declare function getLeaderboardWinOrLose(g: GameContext, type: any, number: any, statKey: any, label: any): Promise<string>;
|
|
8
8
|
export declare function getLeaderboardFastestGuessTime(g: GameContext, type: string, number: number): Promise<string>;
|
|
@@ -6,7 +6,6 @@ export declare function writeIdiomsToFile(g: GameContext, filePath: string, idio
|
|
|
6
6
|
* 接口地址、密钥与模型都来自配置——早先版本把一个真实的 API Key 硬编码在这里。
|
|
7
7
|
*/
|
|
8
8
|
export declare function sendPostRequestForAI(g: GameContext, content: string): Promise<string>;
|
|
9
|
-
export declare function fetchAndParseWords(g: GameContext, url: string): Promise<string>;
|
|
10
9
|
export declare function fetchWordDefinitions(g: GameContext, word: string): Promise<any>;
|
|
11
10
|
export declare function serializeDefinitions(definitions: {
|
|
12
11
|
[part: string]: any;
|
|
@@ -15,10 +14,6 @@ export declare function getIdiomInfo(g: GameContext, idiom: string): Promise<{
|
|
|
15
14
|
pinyin: string;
|
|
16
15
|
explanation: string;
|
|
17
16
|
}>;
|
|
18
|
-
export declare function getIdiomInfo2(g: GameContext, idiom: string): Promise<{
|
|
19
|
-
pinyin: string;
|
|
20
|
-
explanation: string;
|
|
21
|
-
}>;
|
|
22
17
|
export declare function getSelectedIdiom(g: GameContext, randomIdiom: string): Promise<{
|
|
23
18
|
pinyin: string;
|
|
24
19
|
explanation: string;
|
package/lib/types.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
interface Monetary {
|
|
2
|
-
uid: number;
|
|
3
|
-
currency: string;
|
|
4
|
-
value: number;
|
|
5
|
-
}
|
|
6
1
|
export interface GameRecord {
|
|
7
2
|
id: number;
|
|
8
3
|
channelId: string;
|
|
@@ -78,7 +73,6 @@ export interface GamingPlayer {
|
|
|
78
73
|
channelId: string;
|
|
79
74
|
userId: string;
|
|
80
75
|
username: string;
|
|
81
|
-
money: number;
|
|
82
76
|
}
|
|
83
77
|
export interface PlayerRecord {
|
|
84
78
|
id: number;
|
|
@@ -86,7 +80,6 @@ export interface PlayerRecord {
|
|
|
86
80
|
username: string;
|
|
87
81
|
win: number;
|
|
88
82
|
lose: number;
|
|
89
|
-
moneyChange: number;
|
|
90
83
|
wordGuessCount: number;
|
|
91
84
|
stats: PlayerStats;
|
|
92
85
|
fastestGuessTime: Record<string, number>;
|
|
@@ -202,7 +195,5 @@ declare module "koishi" {
|
|
|
202
195
|
extra_wordle_game_records: ExtraGameRecord;
|
|
203
196
|
wordle_gaming_player_records: GamingPlayer;
|
|
204
197
|
wordle_player_records: PlayerRecord;
|
|
205
|
-
monetary: Monetary;
|
|
206
198
|
}
|
|
207
199
|
}
|
|
208
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-wordle-game",
|
|
3
3
|
"description": "Koishi 的多模式猜词游戏插件。",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.9.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
"koishi": {
|
|
16
16
|
"service": {
|
|
17
17
|
"required": [
|
|
18
|
-
"monetary",
|
|
19
18
|
"database",
|
|
20
19
|
"puppeteer"
|
|
21
20
|
]
|
|
@@ -53,7 +52,6 @@
|
|
|
53
52
|
"koishi": "^4.18.11"
|
|
54
53
|
},
|
|
55
54
|
"devDependencies": {
|
|
56
|
-
"koishi-plugin-monetary": "^0.1.3",
|
|
57
55
|
"koishi-plugin-puppeteer": "^3.9.0"
|
|
58
56
|
},
|
|
59
57
|
"dependencies": {
|