koishi-plugin-wordle-game 2.5.0 → 2.5.2
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 +10 -9
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -2280,7 +2280,7 @@ ${rankType3.map((type, index) => `${index + 1}. ${type}`).join('\n')}`}
|
|
|
2280
2280
|
// gm*
|
|
2281
2281
|
ctx.command('wordleGame.改名 [newPlayerName:text]', '更改玩家名字')
|
|
2282
2282
|
.action(async ({ session }, newPlayerName) => {
|
|
2283
|
-
const { userId
|
|
2283
|
+
const { userId } = session;
|
|
2284
2284
|
const username = await getSessionUserName(session);
|
|
2285
2285
|
await updateNameInPlayerRecord(session, userId, username);
|
|
2286
2286
|
newPlayerName = newPlayerName?.trim();
|
|
@@ -2297,21 +2297,22 @@ ${rankType3.map((type, index) => `${index + 1}. ${type}`).join('\n')}`}
|
|
|
2297
2297
|
return sendMessage(session, `新的玩家名字不合法,请重新输入。`, `改名`);
|
|
2298
2298
|
}
|
|
2299
2299
|
if (config.isUsingUnifiedKoishiBuiltInUsername) {
|
|
2300
|
-
return handleUnifiedKoishiUsername(session,
|
|
2300
|
+
return handleUnifiedKoishiUsername(session, newPlayerName);
|
|
2301
2301
|
}
|
|
2302
2302
|
else {
|
|
2303
2303
|
return handleCustomUsername(ctx, session, userId, newPlayerName);
|
|
2304
2304
|
}
|
|
2305
2305
|
});
|
|
2306
2306
|
// hs*
|
|
2307
|
-
async function handleUnifiedKoishiUsername(session,
|
|
2308
|
-
|
|
2309
|
-
|
|
2307
|
+
async function handleUnifiedKoishiUsername(session, newPlayerName) {
|
|
2308
|
+
newPlayerName = koishi_1.h.transform(newPlayerName, { text: true, default: false }).trim();
|
|
2309
|
+
const users = await ctx.database.get('user', {});
|
|
2310
|
+
if (users.some(user => user.name === newPlayerName)) {
|
|
2310
2311
|
return sendMessage(session, `新的玩家名字已经存在,请重新输入。`, `改名`);
|
|
2311
2312
|
}
|
|
2312
2313
|
try {
|
|
2313
|
-
user.name =
|
|
2314
|
-
await user.$update();
|
|
2314
|
+
session.user.name = newPlayerName;
|
|
2315
|
+
await session.user.$update();
|
|
2315
2316
|
return sendMessage(session, `玩家名字已更改为:【${newPlayerName}】`, `查询玩家记录 开始游戏 改名`, 2);
|
|
2316
2317
|
}
|
|
2317
2318
|
catch (error) {
|
|
@@ -2369,13 +2370,13 @@ ${rankType3.map((type, index) => `${index + 1}. ${type}`).join('\n')}`}
|
|
|
2369
2370
|
}
|
|
2370
2371
|
async function getSessionUserName(session) {
|
|
2371
2372
|
let sessionUserName = session.username;
|
|
2372
|
-
const user = session.user;
|
|
2373
2373
|
if (isQQOfficialRobotMarkdownTemplateEnabled && session.platform === 'qq') {
|
|
2374
|
+
const [user] = await ctx.database.get('user', { id: session.user.id });
|
|
2374
2375
|
if (config.isUsingUnifiedKoishiBuiltInUsername && user.name) {
|
|
2375
2376
|
sessionUserName = user.name;
|
|
2376
2377
|
}
|
|
2377
2378
|
else {
|
|
2378
|
-
let userRecord = await ctx.database.get('', { userId: session.userId });
|
|
2379
|
+
let userRecord = await ctx.database.get('wordle_player_records', { userId: session.userId });
|
|
2379
2380
|
if (userRecord.length === 0) {
|
|
2380
2381
|
await ctx.database.create('wordle_player_records', {
|
|
2381
2382
|
userId: session.userId,
|
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/) |... 猜单词|猜成语|猜数字|猜数学方程式|... 的小游戏,支持QQ官方MD模板,且包含多种词库、主题、游戏设置和排行榜系统等。",
|
|
4
|
-
"version": "2.5.
|
|
4
|
+
"version": "2.5.2",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|