koishi-plugin-wordle-game 2.2.9 → 2.3.1
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.js +19 -0
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -1433,6 +1433,7 @@ ${settlementResult}
|
|
|
1433
1433
|
// 更新玩家记录表中的用户名
|
|
1434
1434
|
await updateNameInPlayerRecord(userId, username);
|
|
1435
1435
|
if (targetUser) {
|
|
1436
|
+
targetUser = await replaceAtTags(session, targetUser);
|
|
1436
1437
|
const userIdRegex = /<at id="([^"]+)"(?: name="([^"]+)")?\/>/;
|
|
1437
1438
|
const match = targetUser.match(userIdRegex);
|
|
1438
1439
|
userId = match?.[1] ?? userId;
|
|
@@ -3028,6 +3029,24 @@ ${content}
|
|
|
3028
3029
|
}
|
|
3029
3030
|
}
|
|
3030
3031
|
// hs*
|
|
3032
|
+
async function replaceAtTags(session, content) {
|
|
3033
|
+
// 正则表达式用于匹配 at 标签
|
|
3034
|
+
const atRegex = /<at id="(\d+)"(?: name="([^"]*)")?\/>/g;
|
|
3035
|
+
// 匹配所有 at 标签
|
|
3036
|
+
let match;
|
|
3037
|
+
while ((match = atRegex.exec(content)) !== null) {
|
|
3038
|
+
const userId = match[1];
|
|
3039
|
+
const name = match[2];
|
|
3040
|
+
// 如果 name 不存在,根据 userId 获取相应的 name
|
|
3041
|
+
if (!name) {
|
|
3042
|
+
const guildMember = await session.bot.getGuildMember(session.guildId, userId);
|
|
3043
|
+
// 替换原始的 at 标签
|
|
3044
|
+
const newAtTag = `<at id="${userId}" name="${guildMember.user.name}"/>`;
|
|
3045
|
+
content = content.replace(match[0], newAtTag);
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3048
|
+
return content;
|
|
3049
|
+
}
|
|
3031
3050
|
function checkStrokesData(inputWord) {
|
|
3032
3051
|
for (const char of inputWord) {
|
|
3033
3052
|
if (!strokesData[char]) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-wordle-game",
|
|
3
3
|
"description": "欢迎来到 [Wordle](https://www.nytimes.com/games/wordle/index.html) | [汉兜](https://handle.antfu.me/) | [词影](https://cy.surprising.studio/) |... 猜单词|猜成语|猜数字|猜数学方程式|... 的小游戏,包含多种词库、多种主题、多种游戏设置和排行榜系统。",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.1",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"猜"
|
|
62
62
|
],
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"koishi": "^4.17.
|
|
64
|
+
"koishi": "^4.17.3"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"koishi-plugin-markdown-to-image-service": "^1.1.3",
|