koishi-plugin-game-mini 0.1.5 → 0.1.7

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.d.ts CHANGED
@@ -3,11 +3,29 @@ export declare const name = "game-mini";
3
3
  export declare const using: readonly ["i18n"];
4
4
  export declare const inject: readonly ["console"];
5
5
  export interface Config {
6
+ enableNumberGuess: boolean;
7
+ enableWzHero: boolean;
8
+ enableChengyuImage: boolean;
9
+ enableChengyuJielong: boolean;
6
10
  guessNumber: {
7
11
  min: number;
8
12
  max: number;
9
13
  botParticipateInGroup: boolean;
10
14
  };
15
+ wzHero: {
16
+ botParticipateInGroup: boolean;
17
+ };
18
+ chengyuImage: {
19
+ botParticipateInGroup: boolean;
20
+ };
21
+ chengyuJielong: {
22
+ botParticipateInGroup: boolean;
23
+ };
24
+ apiConfig: {
25
+ wzHeroUserId: string;
26
+ cyjlUserId: string;
27
+ timeout: number;
28
+ };
11
29
  }
12
30
  export declare const Config: Schema<Config>;
13
31
  export declare function apply(ctx: Context, config: Config): void;
package/lib/index.js CHANGED
@@ -9,26 +9,79 @@ const koishi_1 = require("koishi");
9
9
  const fs_1 = __importDefault(require("fs"));
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const yaml_1 = __importDefault(require("yaml"));
12
+ const axios_1 = __importDefault(require("axios"));
12
13
  exports.name = 'game-mini';
13
14
  exports.using = ['i18n'];
14
15
  exports.inject = ['console'];
15
16
  exports.Config = koishi_1.Schema.object({
17
+ enableNumberGuess: koishi_1.Schema.boolean().default(true).description('是否开启猜数字游戏功能'),
18
+ enableWzHero: koishi_1.Schema.boolean().default(true).description('是否开启王者英雄猜谜游戏功能'),
19
+ enableChengyuImage: koishi_1.Schema.boolean().default(true).description('是否开启看图猜成语游戏功能'),
20
+ enableChengyuJielong: koishi_1.Schema.boolean().default(true).description('是否开启成语接龙游戏功能'),
16
21
  guessNumber: koishi_1.Schema.object({
17
22
  min: koishi_1.Schema.number().min(0).default(0).description('猜数字最小值(最低为0)'),
18
23
  max: koishi_1.Schema.number().min(1).default(100).description('猜数字最大值'),
19
- botParticipateInGroup: koishi_1.Schema.boolean().default(true).description('群聊中Bot是否参与(私聊强制参与)')
20
- }).description('猜数字游戏配置')
24
+ botParticipateInGroup: koishi_1.Schema.boolean().default(true).description('群聊中Bot是否参与猜数字(私聊强制参与)')
25
+ }).description('猜数字游戏配置'),
26
+ wzHero: koishi_1.Schema.object({
27
+ botParticipateInGroup: koishi_1.Schema.boolean().default(true).description('群聊中Bot是否参与王者英雄猜谜(私聊强制参与)')
28
+ }).description('王者英雄猜谜配置'),
29
+ chengyuImage: koishi_1.Schema.object({
30
+ botParticipateInGroup: koishi_1.Schema.boolean().default(true).description('群聊中Bot是否参与看图猜成语(私聊强制参与)')
31
+ }).description('看图猜成语配置'),
32
+ chengyuJielong: koishi_1.Schema.object({
33
+ botParticipateInGroup: koishi_1.Schema.boolean().default(true).description('群聊中Bot是否参与成语接龙(私聊强制参与)')
34
+ }).description('成语接龙配置'),
35
+ apiConfig: koishi_1.Schema.object({
36
+ wzHeroUserId: koishi_1.Schema.string().default('1828222534').description('王者英雄猜谜API的用户区分ID(建议填写Bot的QQ号/原生账号)'),
37
+ cyjlUserId: koishi_1.Schema.string().default('1828222534').description('成语接龙API的用户区分ID(建议填写Bot的QQ号/原生账号)'),
38
+ timeout: koishi_1.Schema.number().default(5000).description('第三方API请求超时时间(毫秒)')
39
+ }).description('游戏API配置')
21
40
  }).i18n({
22
41
  'zh-CN': {
42
+ 'enableNumberGuess': '开启猜数字游戏',
43
+ 'enableNumberGuess.description': '控制是否启用猜数字游戏功能',
44
+ 'enableWzHero': '开启王者英雄猜谜',
45
+ 'enableWzHero.description': '控制是否启用王者英雄猜谜游戏功能',
46
+ 'enableChengyuImage': '开启看图猜成语',
47
+ 'enableChengyuImage.description': '控制是否启用看图猜成语游戏功能',
48
+ 'enableChengyuJielong': '开启成语接龙',
49
+ 'enableChengyuJielong.description': '控制是否启用成语接龙游戏功能',
23
50
  'guessNumber.min': '猜数字最小值',
24
51
  'guessNumber.min.description': '设置猜数字游戏的最小值,最低限制为0',
25
52
  'guessNumber.max': '猜数字最大值',
26
53
  'guessNumber.max.description': '设置猜数字游戏的最大值,需大于0',
27
- 'guessNumber.botParticipateInGroup': '群聊Bot参与开关',
54
+ 'guessNumber.botParticipateInGroup': '群聊Bot参与猜数字开关',
28
55
  'guessNumber.botParticipateInGroup.description': '控制Bot是否在群聊中参与猜数字,私聊场景下Bot强制参与',
29
- 'guessNumber': '猜数字游戏配置'
56
+ 'guessNumber': '猜数字游戏配置',
57
+ 'wzHero.botParticipateInGroup': '群聊Bot参与王者英雄猜谜开关',
58
+ 'wzHero.botParticipateInGroup.description': '控制Bot是否在群聊中参与王者英雄猜谜,私聊场景下Bot强制参与',
59
+ 'wzHero': '王者英雄猜谜配置',
60
+ 'chengyuImage.botParticipateInGroup': '群聊Bot参与看图猜成语开关',
61
+ 'chengyuImage.botParticipateInGroup.description': '控制Bot是否在群聊中参与看图猜成语,私聊场景下Bot强制参与',
62
+ 'chengyuImage': '看图猜成语配置',
63
+ 'chengyuJielong.botParticipateInGroup': '群聊Bot参与成语接龙开关',
64
+ 'chengyuJielong.botParticipateInGroup.description': '控制Bot是否在群聊中参与成语接龙,私聊场景下Bot强制参与',
65
+ 'chengyuJielong': '成语接龙配置',
66
+ 'apiConfig.wzHeroUserId': '王者英雄猜谜API用户ID',
67
+ 'apiConfig.wzHeroUserId.description': '用于区分Bot参与的ID,建议填写Bot的QQ号/原生账号',
68
+ 'apiConfig.cyjlUserId': '成语接龙API用户ID',
69
+ 'apiConfig.cyjlUserId.description': '用于区分Bot参与的ID,建议填写Bot的QQ号/原生账号',
70
+ 'apiConfig.timeout': 'API超时时间',
71
+ 'apiConfig.timeout.description': '第三方API请求的超时时间,单位为毫秒',
72
+ 'apiConfig': '游戏API配置'
30
73
  }
31
74
  });
75
+ const logger = new koishi_1.Logger('game-mini');
76
+ const commandDescriptions = {
77
+ guessNumber: '猜数字小游戏指令',
78
+ wzHero: '猜王者荣耀英雄小游戏指令',
79
+ chengyuImage: '看图猜成语小游戏指令',
80
+ chengyuJielong: '成语接龙小游戏指令'
81
+ };
82
+ const getUserRealId = (session) => {
83
+ return session.userId || `${session.platform}_${session.selfId}`;
84
+ };
32
85
  function apply(ctx, config) {
33
86
  const defaultI18n = {
34
87
  guessNumber: {
@@ -42,7 +95,41 @@ function apply(ctx, config) {
42
95
  botWin: '哈哈我猜中了!我猜的是 {0},正确数字就是 {0},我赢啦 🎉',
43
96
  botGuessTooSmall: '我猜 {0},猜小啦!当前范围 [{1}-{2}]',
44
97
  botGuessTooBig: '我猜 {0},猜大啦!当前范围 [{1}-{2}]',
45
- commandDesc: '猜数字小游戏指令'
98
+ disabled: '猜数字游戏功能已关闭,请联系管理员开启',
99
+ },
100
+ wzHero: {
101
+ startUsage: '用法错误!正确用法:wzhero start [难度],难度可选:简单/中等/困难',
102
+ stop: '王者英雄猜谜游戏已停止',
103
+ notStarted: '王者英雄猜谜游戏尚未开始,请输入 wzhero start [难度] 开始游戏',
104
+ hint: '提示',
105
+ apiError: 'API请求失败,请稍后再试',
106
+ botGuess: '让我猜猜~我觉得是:{0}',
107
+ botWrong: '哎呀猜错了😜,继续猜猜看!',
108
+ botRight: '耶!我猜对了~就是{0} ✨',
109
+ disabled: '王者英雄猜谜功能已关闭,请联系管理员开启',
110
+ },
111
+ chengyuImage: {
112
+ start: '看图猜成语游戏开始!',
113
+ stop: '看图猜成语游戏已停止',
114
+ submitUsage: '请直接输入你猜测的成语,或输入 提示 获取线索',
115
+ notStarted: '看图猜成语游戏尚未开始,请输入 cyimage start 开始游戏',
116
+ next: '下一题来啦!',
117
+ hintUsage: '提示等级可选1-5,用法:提示 <等级>,如 提示 2',
118
+ apiError: 'API请求失败,请稍后再试',
119
+ botGuess: '我来试试!我猜是:{0}',
120
+ botWrong: '猜错了😭,换个试试!',
121
+ botRight: '太棒了!我猜对了~就是{0} 🎊',
122
+ disabled: '看图猜成语功能已关闭,请联系管理员开启',
123
+ },
124
+ chengyuJielong: {
125
+ start: '成语接龙游戏开始!我先来~',
126
+ stop: '成语接龙游戏已停止',
127
+ notStarted: '成语接龙游戏尚未开始,请输入 cyjl start 开始游戏',
128
+ joinUsage: '请输入 我接<成语> 进行接龙,如 我接一帆风顺',
129
+ apiError: 'API请求失败,请稍后再试',
130
+ botTurn: '该我了!我接:{0}({1})\n释义:{2}',
131
+ botWin: '哈哈我接不上了,你赢啦~',
132
+ disabled: '成语接龙功能已关闭,请联系管理员开启',
46
133
  }
47
134
  };
48
135
  try {
@@ -56,103 +143,607 @@ function apply(ctx, config) {
56
143
  }
57
144
  }
58
145
  catch (e) {
146
+ logger.warn('加载i18n配置失败,使用默认配置:', e);
59
147
  ctx.i18n.define('zh-CN', defaultI18n);
60
148
  }
61
- const guessNumberStates = new Map();
149
+ const gameStates = new Map();
62
150
  const getSessionKey = (session) => session.channelId ? `group:${session.channelId}` : `private:${session.userId}`;
151
+ const getBotParticipate = (session, gameType) => {
152
+ const isPrivate = !session.channelId;
153
+ if (isPrivate)
154
+ return true;
155
+ switch (gameType) {
156
+ case 'guessNumber':
157
+ return config.guessNumber.botParticipateInGroup;
158
+ case 'wzHero':
159
+ return config.wzHero.botParticipateInGroup;
160
+ case 'chengyuImage':
161
+ return config.chengyuImage.botParticipateInGroup;
162
+ case 'chengyuJielong':
163
+ return config.chengyuJielong.botParticipateInGroup;
164
+ default:
165
+ return true;
166
+ }
167
+ };
168
+ const initSessionState = (key) => {
169
+ const state = {
170
+ guessNumber: {
171
+ target: 0,
172
+ currentMin: config.guessNumber.min,
173
+ currentMax: config.guessNumber.max,
174
+ started: false,
175
+ botGuess: []
176
+ },
177
+ wzHero: {
178
+ started: false,
179
+ difficulty: '',
180
+ botAnswered: false,
181
+ lastHint: ''
182
+ },
183
+ chengyuImage: {
184
+ started: false,
185
+ currentId: '',
186
+ currentPage: 1,
187
+ botGuessed: false,
188
+ options: []
189
+ },
190
+ chengyuJielong: {
191
+ started: false,
192
+ lastChar: '',
193
+ botTurn: true
194
+ }
195
+ };
196
+ gameStates.set(key, state);
197
+ return state;
198
+ };
63
199
  ctx.middleware(async (session, next) => {
64
200
  if (!session.content)
65
201
  return next();
66
202
  const key = getSessionKey(session);
67
- const state = guessNumberStates.get(key);
68
- if (!state || !state.started)
69
- return next();
70
- const num = parseInt(session.content.trim());
71
- if (isNaN(num) || !Number.isInteger(num))
72
- return next();
73
- let reply = '';
74
- if (num < state.currentMin || num > state.currentMax) {
75
- reply = session.text('guessNumber.outOfRange', [state.currentMin, state.currentMax]);
76
- }
77
- else if (num < state.target) {
78
- state.currentMin = num + 1;
79
- reply = session.text('guessNumber.tooSmall', [state.currentMin, state.currentMax]);
203
+ const state = gameStates.get(key) || initSessionState(key);
204
+ if (config.enableNumberGuess && state.guessNumber.started) {
205
+ const num = parseInt(session.content.trim());
206
+ if (!isNaN(num) && Number.isInteger(num)) {
207
+ let reply = '';
208
+ const gnState = state.guessNumber;
209
+ if (num < gnState.currentMin || num > gnState.currentMax) {
210
+ reply = session.text('guessNumber.outOfRange', [gnState.currentMin, gnState.currentMax]);
211
+ }
212
+ else if (num < gnState.target) {
213
+ gnState.currentMin = num + 1;
214
+ reply = session.text('guessNumber.tooSmall', [gnState.currentMin, gnState.currentMax]);
215
+ }
216
+ else if (num > gnState.target) {
217
+ gnState.currentMax = num - 1;
218
+ reply = session.text('guessNumber.tooBig', [gnState.currentMin, gnState.currentMax]);
219
+ }
220
+ else {
221
+ gnState.started = false;
222
+ gameStates.set(key, state);
223
+ reply = session.text('guessNumber.correct', [gnState.target]);
224
+ await session.send(reply);
225
+ return;
226
+ }
227
+ gameStates.set(key, state);
228
+ const botPlay = getBotParticipate(session, 'guessNumber');
229
+ if (botPlay && gnState.started && gnState.currentMin <= gnState.currentMax) {
230
+ let botGuess;
231
+ let safe = 0;
232
+ do {
233
+ botGuess = koishi_1.Random.int(gnState.currentMin, gnState.currentMax);
234
+ safe++;
235
+ } while ((botGuess === gnState.target || gnState.botGuess.includes(botGuess)) && safe < 20);
236
+ gnState.botGuess.push(botGuess);
237
+ if (botGuess === gnState.target) {
238
+ reply += session.text('guessNumber.botWin', [botGuess]);
239
+ gnState.started = false;
240
+ }
241
+ else if (botGuess < gnState.target) {
242
+ gnState.currentMin = botGuess + 1;
243
+ reply += session.text('guessNumber.botGuessTooSmall', [botGuess, gnState.currentMin, gnState.currentMax]);
244
+ }
245
+ else {
246
+ gnState.currentMax = botGuess - 1;
247
+ reply += session.text('guessNumber.botGuessTooBig', [botGuess, gnState.currentMin, gnState.currentMax]);
248
+ }
249
+ gameStates.set(key, state);
250
+ }
251
+ await session.send(reply);
252
+ return;
253
+ }
80
254
  }
81
- else if (num > state.target) {
82
- state.currentMax = num - 1;
83
- reply = session.text('guessNumber.tooBig', [state.currentMin, state.currentMax]);
255
+ if (config.enableWzHero && state.wzHero.started) {
256
+ const content = session.content.trim();
257
+ const wzState = state.wzHero;
258
+ try {
259
+ const response = await axios_1.default.get('https://api.suol.cc/v1/game_wz.php', {
260
+ params: {
261
+ id: getUserRealId(session),
262
+ msg: content
263
+ },
264
+ timeout: config.apiConfig.timeout
265
+ });
266
+ const data = response.data;
267
+ let reply = '';
268
+ if (data.status === 'success') {
269
+ if (data.message.includes('用完了所有提示') || data.remaining_hints === 0) {
270
+ reply = '很遗憾,你用完了所有提示!难度太大?可以向我发送“wzhero start 简单”以降低猜测英雄难度。游戏开始!当前难度:简单\n请看题,下面是一首描写该英雄的诗词。\n胡笳琴韵愈伤痕\n弹弹连控摄敌魂\n加血提速护友紧\n奶妈之名天下闻\n请输入你猜测的英雄名称,或输入"提示"获取下一条线索';
271
+ }
272
+ else {
273
+ reply = `${data.message || ''}\n${data.hint || ''}\n剩余提示次数:${data.remaining_hints}\n${data.guide || ''}`;
274
+ wzState.lastHint = data.hint || '';
275
+ }
276
+ }
277
+ else {
278
+ reply = data.message || '游戏出错了,请稍后再试';
279
+ }
280
+ await session.send(reply);
281
+ const botPlay = getBotParticipate(session, 'wzHero');
282
+ if (botPlay && !wzState.botAnswered) {
283
+ setTimeout(async () => {
284
+ const heroList = ['李白', '韩信', '貂蝉', '诸葛亮', '妲己', '亚瑟', '鲁班七号', '孙尚香', '孙悟空', '安琪拉'];
285
+ const randomHero = heroList[Math.floor(Math.random() * heroList.length)];
286
+ const botResponse = await axios_1.default.get('https://api.suol.cc/v1/game_wz.php', {
287
+ params: {
288
+ id: config.apiConfig.wzHeroUserId,
289
+ msg: randomHero
290
+ },
291
+ timeout: config.apiConfig.timeout
292
+ });
293
+ let botReply = session.text('wzHero.botGuess', [randomHero]);
294
+ if (botResponse.data.status !== 'success' || botResponse.data.message.includes('错误') || botResponse.data.message.includes('不对')) {
295
+ botReply += '\n' + session.text('wzHero.botWrong');
296
+ }
297
+ else {
298
+ botReply += '\n' + session.text('wzHero.botRight', [randomHero]);
299
+ wzState.started = false;
300
+ }
301
+ wzState.botAnswered = true;
302
+ gameStates.set(key, state);
303
+ await session.send(botReply);
304
+ }, 3000);
305
+ }
306
+ }
307
+ catch (error) {
308
+ logger.error('王者英雄猜谜API请求失败:', error);
309
+ await session.send(session.text('wzHero.apiError'));
310
+ }
311
+ return;
84
312
  }
85
- else {
86
- state.started = false;
87
- guessNumberStates.set(key, state);
88
- reply = session.text('guessNumber.correct', [state.target]);
89
- await session.send(reply);
313
+ if (config.enableChengyuImage && state.chengyuImage.started) {
314
+ const content = session.content.trim();
315
+ const cyImageState = state.chengyuImage;
316
+ const currentId = cyImageState.currentId;
317
+ try {
318
+ let reply = '';
319
+ if (content.startsWith('提示')) {
320
+ const level = content.split(' ')[1] || '1';
321
+ const levelNum = parseInt(level);
322
+ const validLevel = isNaN(levelNum) || levelNum < 1 || levelNum > 5 ? 1 : levelNum;
323
+ const response = await axios_1.default.get('https://jcy.lvlong.xyz/api/api/chengyu.php', {
324
+ params: {
325
+ action: 'get_hint',
326
+ id: currentId,
327
+ level: validLevel
328
+ },
329
+ timeout: config.apiConfig.timeout
330
+ });
331
+ const data = response.data;
332
+ reply = data.success ? data.message : '获取提示失败,请稍后再试';
333
+ }
334
+ else if (content === '下一题') {
335
+ const response = await axios_1.default.get('https://jcy.lvlong.xyz/api/api/chengyu.php', {
336
+ params: {
337
+ action: 'next_question',
338
+ page: cyImageState.currentPage + 1
339
+ },
340
+ timeout: config.apiConfig.timeout
341
+ });
342
+ const data = response.data;
343
+ if (data.success) {
344
+ cyImageState.currentId = data.data.question.id;
345
+ cyImageState.currentPage = data.data.question.page;
346
+ cyImageState.options = data.data.question.options;
347
+ cyImageState.botGuessed = false;
348
+ gameStates.set(key, state);
349
+ reply = `${session.text('chengyuImage.next')}\n${data.data.message}\n选项:${data.data.question.options.join('、')}\n[CQ:image,file=${data.data.question.image_url}]`;
350
+ }
351
+ else {
352
+ reply = '获取下一题失败,请稍后再试';
353
+ }
354
+ }
355
+ else {
356
+ const response = await axios_1.default.get('https://jcy.lvlong.xyz/api/api/chengyu.php', {
357
+ params: {
358
+ action: 'submit_answer',
359
+ id: currentId,
360
+ answer: content
361
+ },
362
+ timeout: config.apiConfig.timeout
363
+ });
364
+ const data = response.data;
365
+ if (data.success) {
366
+ reply = data.message;
367
+ if (data.message.includes('正确') || data.message.includes('答对')) {
368
+ state.chengyuImage.started = false;
369
+ }
370
+ }
371
+ else {
372
+ reply = '提交答案失败,请稍后再试';
373
+ }
374
+ }
375
+ await session.send(reply);
376
+ const botPlay = getBotParticipate(session, 'chengyuImage');
377
+ if (botPlay && !cyImageState.botGuessed && cyImageState.options.length > 0) {
378
+ setTimeout(async () => {
379
+ const randomWords = [];
380
+ for (let i = 0; i < 4; i++) {
381
+ if (cyImageState.options.length > i) {
382
+ randomWords.push(cyImageState.options[Math.floor(Math.random() * cyImageState.options.length)]);
383
+ }
384
+ }
385
+ const randomIdiom = randomWords.join('');
386
+ const botResponse = await axios_1.default.get('https://jcy.lvlong.xyz/api/api/chengyu.php', {
387
+ params: {
388
+ action: 'submit_answer',
389
+ id: currentId,
390
+ answer: randomIdiom
391
+ },
392
+ timeout: config.apiConfig.timeout
393
+ });
394
+ let botReply = session.text('chengyuImage.botGuess', [randomIdiom]);
395
+ if (botResponse.data.message.includes('错误') || botResponse.data.message.includes('不对')) {
396
+ botReply += '\n' + session.text('chengyuImage.botWrong');
397
+ }
398
+ else {
399
+ botReply += '\n' + session.text('chengyuImage.botRight', [randomIdiom]);
400
+ cyImageState.started = false;
401
+ }
402
+ cyImageState.botGuessed = true;
403
+ gameStates.set(key, state);
404
+ await session.send(botReply);
405
+ }, 3000);
406
+ }
407
+ }
408
+ catch (error) {
409
+ logger.error('看图猜成语API请求失败:', error);
410
+ await session.send(session.text('chengyuImage.apiError'));
411
+ }
90
412
  return;
91
413
  }
92
- guessNumberStates.set(key, state);
93
- const isPrivate = !session.channelId;
94
- const botPlay = isPrivate || config.guessNumber.botParticipateInGroup;
95
- if (botPlay && state.started && state.currentMin <= state.currentMax) {
96
- let botGuess;
97
- let safe = 0;
98
- do {
99
- botGuess = koishi_1.Random.int(state.currentMin, state.currentMax);
100
- safe++;
101
- } while ((botGuess === state.target || state.botGuess.includes(botGuess)) && safe < 20);
102
- state.botGuess.push(botGuess);
103
- guessNumberStates.set(key, state);
104
- if (botGuess === state.target) {
105
- reply += session.text('guessNumber.botWin', [botGuess]);
106
- state.started = false;
107
- guessNumberStates.set(key, state);
108
- }
109
- else if (botGuess < state.target) {
110
- state.currentMin = botGuess + 1;
111
- guessNumberStates.set(key, state);
112
- reply += session.text('guessNumber.botGuessTooSmall', [botGuess, state.currentMin, state.currentMax]);
414
+ if (config.enableChengyuJielong && state.chengyuJielong.started) {
415
+ const content = session.content.trim();
416
+ const cyJlState = state.chengyuJielong;
417
+ if (!content.startsWith('我接')) {
418
+ await session.send(session.text('chengyuJielong.joinUsage'));
419
+ return;
113
420
  }
114
- else {
115
- state.currentMax = botGuess - 1;
116
- guessNumberStates.set(key, state);
117
- reply += session.text('guessNumber.botGuessTooBig', [botGuess, state.currentMin, state.currentMax]);
421
+ const idiom = content.substring(2).trim();
422
+ if (!idiom) {
423
+ await session.send(session.text('chengyuJielong.joinUsage'));
424
+ return;
425
+ }
426
+ try {
427
+ const response = await axios_1.default.get('https://api.suol.cc/v1/game_cyjl.php', {
428
+ params: {
429
+ id: getUserRealId(session),
430
+ msg: `我接${idiom}`
431
+ },
432
+ timeout: config.apiConfig.timeout
433
+ });
434
+ const data = response.data;
435
+ let reply = '';
436
+ if (data.code === 200) {
437
+ reply = `${data.msg}\n`;
438
+ if (data.data.user) {
439
+ reply += `你的成语:${data.data.user.idiom}(${data.data.user.pinyin})\n释义:${data.data.user.meaning}\n`;
440
+ cyJlState.lastChar = data.data.current_char || '';
441
+ }
442
+ if (data.data.system) {
443
+ reply += `我的接龙:${data.data.system.idiom}(${data.data.system.pinyin})\n释义:${data.data.system.meaning}\n当前接字:${data.data.current_char}`;
444
+ cyJlState.lastChar = data.data.current_char || '';
445
+ }
446
+ }
447
+ else {
448
+ reply = data.msg || '接龙失败,请换个成语试试';
449
+ }
450
+ await session.send(reply);
451
+ const botPlay = getBotParticipate(session, 'chengyuJielong');
452
+ if (botPlay && cyJlState.lastChar) {
453
+ setTimeout(async () => {
454
+ const botResponse = await axios_1.default.get('https://api.suol.cc/v1/game_cyjl.php', {
455
+ params: {
456
+ id: config.apiConfig.cyjlUserId,
457
+ msg: `开始成语接龙`
458
+ },
459
+ timeout: config.apiConfig.timeout
460
+ });
461
+ if (botResponse.data.code === 200 && botResponse.data.data.system) {
462
+ const botIdiom = botResponse.data.data.system.idiom;
463
+ const botPinyin = botResponse.data.data.system.pinyin;
464
+ const botMeaning = botResponse.data.data.system.meaning;
465
+ const botChar = botResponse.data.data.current_char;
466
+ const botReply = session.text('chengyuJielong.botTurn', [botIdiom, botPinyin, botMeaning]);
467
+ cyJlState.lastChar = botChar;
468
+ gameStates.set(key, state);
469
+ await session.send(botReply);
470
+ }
471
+ }, 2000);
472
+ }
118
473
  }
474
+ catch (error) {
475
+ logger.error('成语接龙API请求失败:', error);
476
+ await session.send(session.text('chengyuJielong.apiError'));
477
+ }
478
+ return;
119
479
  }
120
- await session.send(reply);
480
+ return next();
121
481
  });
122
- ctx.command('guess <action:string>', '猜数字小游戏指令')
123
- .action(async ({ session }, action) => {
124
- if (!session)
482
+ if (config.enableNumberGuess) {
483
+ ctx.command('guess <action:string>', commandDescriptions.guessNumber)
484
+ .action(async (argv, action) => {
485
+ const session = argv.session;
486
+ if (!session || !action) {
487
+ await session?.send(session.text('guessNumber.usage'));
488
+ return '';
489
+ }
490
+ const key = getSessionKey(session);
491
+ const state = gameStates.get(key) || initSessionState(key);
492
+ if (action === 'start') {
493
+ state.guessNumber.target = koishi_1.Random.int(config.guessNumber.min, config.guessNumber.max);
494
+ state.guessNumber.currentMin = config.guessNumber.min;
495
+ state.guessNumber.currentMax = config.guessNumber.max;
496
+ state.guessNumber.started = true;
497
+ state.guessNumber.botGuess = [];
498
+ gameStates.set(key, state);
499
+ await session.send(session.text('guessNumber.start', [config.guessNumber.min, config.guessNumber.max]));
500
+ const botPlay = getBotParticipate(session, 'guessNumber');
501
+ if (botPlay) {
502
+ setTimeout(async () => {
503
+ const botGuess = koishi_1.Random.int(config.guessNumber.min, config.guessNumber.max);
504
+ state.guessNumber.botGuess.push(botGuess);
505
+ gameStates.set(key, state);
506
+ let botReply = '';
507
+ if (botGuess < state.guessNumber.target) {
508
+ state.guessNumber.currentMin = botGuess + 1;
509
+ botReply = session.text('guessNumber.botGuessTooSmall', [botGuess, state.guessNumber.currentMin, state.guessNumber.currentMax]);
510
+ }
511
+ else if (botGuess > state.guessNumber.target) {
512
+ state.guessNumber.currentMax = botGuess - 1;
513
+ botReply = session.text('guessNumber.botGuessTooBig', [botGuess, state.guessNumber.currentMin, state.guessNumber.currentMax]);
514
+ }
515
+ else {
516
+ botReply = session.text('guessNumber.botWin', [botGuess]);
517
+ state.guessNumber.started = false;
518
+ }
519
+ gameStates.set(key, state);
520
+ await session.send(botReply);
521
+ }, 1000);
522
+ }
523
+ }
524
+ else if (action === 'stop') {
525
+ state.guessNumber.started = false;
526
+ gameStates.set(key, state);
527
+ await session.send(session.text('guessNumber.stop', [state.guessNumber.target]));
528
+ }
529
+ else {
530
+ await session.send(session.text('guessNumber.usage'));
531
+ }
125
532
  return '';
126
- const key = getSessionKey(session);
127
- let state = guessNumberStates.get(key) || {
128
- target: 0,
129
- currentMin: config.guessNumber.min,
130
- currentMax: config.guessNumber.max,
131
- started: false,
132
- botGuess: []
133
- };
134
- if (!action) {
135
- await session.send(session.text('guessNumber.usage'));
533
+ });
534
+ }
535
+ if (config.enableWzHero) {
536
+ ctx.command('wzhero <action:string> [difficulty:string]', commandDescriptions.wzHero)
537
+ .usage('用法:wzhero start [难度],难度可选:简单/中等/困难,默认中等')
538
+ .action(async (argv, action, difficulty) => {
539
+ const session = argv.session;
540
+ if (!session || !action) {
541
+ await session?.send('用法错误!正确用法:wzhero start [难度],难度可选:简单/中等/困难');
542
+ return '';
543
+ }
544
+ const key = getSessionKey(session);
545
+ const state = gameStates.get(key) || initSessionState(key);
546
+ if (action === 'start') {
547
+ const finalDifficulty = difficulty || '中等';
548
+ if (!['简单', '中等', '困难'].includes(finalDifficulty)) {
549
+ await session.send('用法错误!正确用法:wzhero start [难度],难度可选:简单/中等/困难');
550
+ return '';
551
+ }
552
+ state.wzHero.started = true;
553
+ state.wzHero.difficulty = finalDifficulty;
554
+ state.wzHero.botAnswered = false;
555
+ gameStates.set(key, state);
556
+ try {
557
+ const response = await axios_1.default.get('https://api.suol.cc/v1/game_wz.php', {
558
+ params: {
559
+ id: getUserRealId(session),
560
+ msg: `开始游戏${finalDifficulty}`
561
+ },
562
+ timeout: config.apiConfig.timeout
563
+ });
564
+ const data = response.data;
565
+ let reply = '';
566
+ if (data.status === 'success') {
567
+ reply = `${data.message || ''}\n${data.hint || ''}\n${data.guide || ''}`;
568
+ state.wzHero.lastHint = data.hint || '';
569
+ }
570
+ else {
571
+ reply = data.message || '游戏开始失败,请稍后再试';
572
+ }
573
+ await session.send(reply);
574
+ const botPlay = getBotParticipate(session, 'wzHero');
575
+ if (botPlay) {
576
+ setTimeout(async () => {
577
+ const heroList = ['李白', '韩信', '貂蝉', '诸葛亮', '妲己', '亚瑟', '鲁班七号', '孙尚香', '孙悟空', '安琪拉'];
578
+ const randomHero = heroList[Math.floor(Math.random() * heroList.length)];
579
+ const botResponse = await axios_1.default.get('https://api.suol.cc/v1/game_wz.php', {
580
+ params: {
581
+ id: config.apiConfig.wzHeroUserId,
582
+ msg: randomHero
583
+ },
584
+ timeout: config.apiConfig.timeout
585
+ });
586
+ let botReply = session.text('wzHero.botGuess', [randomHero]);
587
+ if (botResponse.data.status !== 'success' || botResponse.data.message.includes('错误') || botResponse.data.message.includes('不对')) {
588
+ botReply += '\n' + session.text('wzHero.botWrong');
589
+ }
590
+ else {
591
+ botReply += '\n' + session.text('wzHero.botRight', [randomHero]);
592
+ state.wzHero.started = false;
593
+ }
594
+ state.wzHero.botAnswered = true;
595
+ gameStates.set(key, state);
596
+ await session.send(botReply);
597
+ }, 2000);
598
+ }
599
+ }
600
+ catch (error) {
601
+ logger.error('王者英雄猜谜开始游戏失败:', error);
602
+ await session.send(session.text('wzHero.apiError'));
603
+ state.wzHero.started = false;
604
+ gameStates.set(key, state);
605
+ }
606
+ }
607
+ else if (action === 'stop') {
608
+ state.wzHero.started = false;
609
+ gameStates.set(key, state);
610
+ await session.send(session.text('wzHero.stop'));
611
+ }
612
+ else {
613
+ await session.send('用法错误!正确用法:wzhero start [难度],难度可选:简单/中等/困难');
614
+ }
136
615
  return '';
137
- }
138
- if (action === 'start') {
139
- state.target = koishi_1.Random.int(config.guessNumber.min, config.guessNumber.max);
140
- state.currentMin = config.guessNumber.min;
141
- state.currentMax = config.guessNumber.max;
142
- state.started = true;
143
- state.botGuess = [];
144
- guessNumberStates.set(key, state);
145
- const msg = session.text('guessNumber.start', [config.guessNumber.min, config.guessNumber.max]);
146
- await session.send(msg);
616
+ });
617
+ }
618
+ if (config.enableChengyuImage) {
619
+ ctx.command('cyimage <action:string>', commandDescriptions.chengyuImage)
620
+ .action(async (argv, action) => {
621
+ const session = argv.session;
622
+ if (!session || !action) {
623
+ await session?.send(session.text('chengyuImage.submitUsage'));
624
+ return '';
625
+ }
626
+ const key = getSessionKey(session);
627
+ const state = gameStates.get(key) || initSessionState(key);
628
+ if (action === 'start') {
629
+ try {
630
+ const response = await axios_1.default.get('https://jcy.lvlong.xyz/api/api/chengyu.php', {
631
+ params: {
632
+ action: 'get_question'
633
+ },
634
+ timeout: config.apiConfig.timeout
635
+ });
636
+ const data = response.data;
637
+ if (data.success) {
638
+ state.chengyuImage.started = true;
639
+ state.chengyuImage.currentId = data.data.question.id;
640
+ state.chengyuImage.currentPage = data.data.question.page;
641
+ state.chengyuImage.options = data.data.question.options;
642
+ state.chengyuImage.botGuessed = false;
643
+ gameStates.set(key, state);
644
+ const reply = `${session.text('chengyuImage.start')}\n${data.data.message}\n选项:${data.data.question.options.join('、')}\n[CQ:image,file=${data.data.question.image_url}]`;
645
+ await session.send(reply);
646
+ const botPlay = getBotParticipate(session, 'chengyuImage');
647
+ if (botPlay) {
648
+ setTimeout(async () => {
649
+ const randomWords = [];
650
+ for (let i = 0; i < 4; i++) {
651
+ if (data.data.question.options.length > i) {
652
+ randomWords.push(data.data.question.options[Math.floor(Math.random() * data.data.question.options.length)]);
653
+ }
654
+ }
655
+ const randomIdiom = randomWords.join('');
656
+ const botResponse = await axios_1.default.get('https://jcy.lvlong.xyz/api/api/chengyu.php', {
657
+ params: {
658
+ action: 'submit_answer',
659
+ id: data.data.question.id,
660
+ answer: randomIdiom
661
+ },
662
+ timeout: config.apiConfig.timeout
663
+ });
664
+ let botReply = session.text('chengyuImage.botGuess', [randomIdiom]);
665
+ if (botResponse.data.message.includes('错误') || botResponse.data.message.includes('不对')) {
666
+ botReply += '\n' + session.text('chengyuImage.botWrong');
667
+ }
668
+ else {
669
+ botReply += '\n' + session.text('chengyuImage.botRight', [randomIdiom]);
670
+ state.chengyuImage.started = false;
671
+ }
672
+ state.chengyuImage.botGuessed = true;
673
+ gameStates.set(key, state);
674
+ await session.send(botReply);
675
+ }, 2000);
676
+ }
677
+ }
678
+ else {
679
+ await session.send('获取题目失败,请稍后再试');
680
+ }
681
+ }
682
+ catch (error) {
683
+ logger.error('看图猜成语开始游戏失败:', error);
684
+ await session.send(session.text('chengyuImage.apiError'));
685
+ }
686
+ }
687
+ else if (action === 'stop') {
688
+ state.chengyuImage.started = false;
689
+ gameStates.set(key, state);
690
+ await session.send(session.text('chengyuImage.stop'));
691
+ }
692
+ else {
693
+ await session.send(session.text('chengyuImage.submitUsage'));
694
+ }
147
695
  return '';
148
- }
149
- if (action === 'stop') {
150
- state.started = false;
151
- guessNumberStates.set(key, state);
152
- await session.send(session.text('guessNumber.stop', [state.target]));
696
+ });
697
+ }
698
+ if (config.enableChengyuJielong) {
699
+ ctx.command('cyjl <action:string>', commandDescriptions.chengyuJielong)
700
+ .action(async (argv, action) => {
701
+ const session = argv.session;
702
+ if (!session || !action) {
703
+ await session?.send(session.text('chengyuJielong.joinUsage'));
704
+ return '';
705
+ }
706
+ const key = getSessionKey(session);
707
+ const state = gameStates.get(key) || initSessionState(key);
708
+ if (action === 'start') {
709
+ state.chengyuJielong.started = true;
710
+ state.chengyuJielong.botTurn = true;
711
+ gameStates.set(key, state);
712
+ try {
713
+ const response = await axios_1.default.get('https://api.suol.cc/v1/game_cyjl.php', {
714
+ params: {
715
+ id: getUserRealId(session),
716
+ msg: '开始成语接龙'
717
+ },
718
+ timeout: config.apiConfig.timeout
719
+ });
720
+ const data = response.data;
721
+ let reply = session.text('chengyuJielong.start');
722
+ if (data.code === 200) {
723
+ reply += `\n我的第一个成语:${data.data.system.idiom}(${data.data.system.pinyin})\n释义:${data.data.system.meaning}\n当前接字:${data.data.current_char}`;
724
+ state.chengyuJielong.lastChar = data.data.current_char || '';
725
+ }
726
+ else {
727
+ reply = data.msg || '游戏开始失败,请稍后再试';
728
+ }
729
+ await session.send(reply);
730
+ }
731
+ catch (error) {
732
+ logger.error('成语接龙开始游戏失败:', error);
733
+ await session.send(session.text('chengyuJielong.apiError'));
734
+ state.chengyuJielong.started = false;
735
+ gameStates.set(key, state);
736
+ }
737
+ }
738
+ else if (action === 'stop') {
739
+ state.chengyuJielong.started = false;
740
+ gameStates.set(key, state);
741
+ await session.send(session.text('chengyuJielong.stop'));
742
+ }
743
+ else {
744
+ await session.send(session.text('chengyuJielong.joinUsage'));
745
+ }
153
746
  return '';
154
- }
155
- await session.send(session.text('guessNumber.usage'));
156
- return '';
157
- });
747
+ });
748
+ }
158
749
  }
@@ -1,12 +1,47 @@
1
+ # locales/zh-CN.yml
1
2
  guessNumber:
2
- usage: 用法错误!正确用法:guess start/stop 或 直接输入数字
3
- start: 猜数字游戏开始!初始范围是 {0}-{1},快来猜猜看~
4
- stop: 猜数字游戏已停止,正确数字是 {0}
5
- outOfRange: 数字超出当前范围 [{0}-{1}],请重新输入!
6
- tooSmall: 猜小啦!当前范围更新为 [{0}-{1}]
7
- tooBig: 猜大啦!当前范围更新为 [{0}-{1}]
8
- correct: 恭喜你猜中了!正确数字就是 {0} 🎉
9
- botWin: 哈哈我猜中了!我猜的是 {0},正确数字就是 {0},我赢啦 🎉
10
- botGuessTooSmall: 我猜 {0},猜小啦!当前范围 [{1}-{2}]
11
- botGuessTooBig: 我猜 {0},猜大啦!当前范围 [{1}-{2}]
12
- commandDesc: 猜数字小游戏指令
3
+ usage: "用法错误!正确用法:guess start/stop 或 直接输入数字"
4
+ start: "猜数字游戏开始!初始范围是 {0}-{1},快来猜猜看~"
5
+ stop: "猜数字游戏已停止,正确数字是 {0}"
6
+ outOfRange: "数字超出当前范围 [{0}-{1}],请重新输入!"
7
+ tooSmall: "猜小啦!当前范围更新为 [{0}-{1}]"
8
+ tooBig: "猜大啦!当前范围更新为 [{0}-{1}]"
9
+ correct: "恭喜你猜中了!正确数字就是 {0} 🎉"
10
+ botWin: "哈哈我猜中了!我猜的是 {0},正确数字就是 {0},我赢啦 🎉"
11
+ botGuessTooSmall: "我猜 {0},猜小啦!当前范围 [{1}-{2}]"
12
+ botGuessTooBig: "我猜 {0},猜大啦!当前范围 [{1}-{2}]"
13
+ disabled: "猜数字游戏功能已关闭,请联系管理员开启"
14
+
15
+ wzHero:
16
+ startUsage: "用法错误!正确用法:wzhero start [难度],难度可选:简单/中等/困难"
17
+ stop: "王者英雄猜谜游戏已停止"
18
+ notStarted: "王者英雄猜谜游戏尚未开始,请输入 wzhero start [难度] 开始游戏"
19
+ hint: "提示"
20
+ apiError: "API请求失败,请稍后再试"
21
+ botGuess: "让我猜猜~我觉得是:{0}"
22
+ botWrong: "哎呀猜错了😜,继续猜猜看!"
23
+ botRight: "耶!我猜对了~就是{0} ✨"
24
+ disabled: "王者英雄猜谜功能已关闭,请联系管理员开启"
25
+
26
+ chengyuImage:
27
+ start: "看图猜成语游戏开始!"
28
+ stop: "看图猜成语游戏已停止"
29
+ submitUsage: "请直接输入你猜测的成语,或输入 提示 获取线索"
30
+ notStarted: "看图猜成语游戏尚未开始,请输入 cyimage start 开始游戏"
31
+ next: "下一题来啦!"
32
+ hintUsage: "提示等级可选1-5,用法:提示 <等级>,如 提示 2"
33
+ apiError: "API请求失败,请稍后再试"
34
+ botGuess: "我来试试!我猜是:{0}"
35
+ botWrong: "猜错了😭,换个试试!"
36
+ botRight: "太棒了!我猜对了~就是{0} 🎊"
37
+ disabled: "看图猜成语功能已关闭,请联系管理员开启"
38
+
39
+ chengyuJielong:
40
+ start: "成语接龙游戏开始!我先来~"
41
+ stop: "成语接龙游戏已停止"
42
+ notStarted: "成语接龙游戏尚未开始,请输入 cyjl start 开始游戏"
43
+ joinUsage: "请输入 我接<成语> 进行接龙,如 我接一帆风顺"
44
+ apiError: "API请求失败,请稍后再试"
45
+ botTurn: "该我了!我接:{0}({1})\n释义:{2}"
46
+ botWin: "哈哈我接不上了,你赢啦~"
47
+ disabled: "成语接龙功能已关闭,请联系管理员开启"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-game-mini",
3
- "version": "0.1.5",
4
- "description": "一款简单的猜数字小游戏,支持Bot参与",
3
+ "version": "0.1.7",
4
+ "description": "一款包含猜数字、猜王者英雄、看图猜成语、成语接龙的多功能小游戏插件",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -14,7 +14,10 @@
14
14
  "koishi",
15
15
  "plugin",
16
16
  "game",
17
- "猜数字"
17
+ "猜数字",
18
+ "王者荣耀",
19
+ "猜成语",
20
+ "成语接龙"
18
21
  ],
19
22
  "author": "Minecraft-1314",
20
23
  "license": "MIT",
@@ -28,10 +31,13 @@
28
31
  "homepage": "https://github.com/Minecraft-1314/koishi-plugin-game-mini#readme",
29
32
  "peerDependencies": {
30
33
  "koishi": "^4.0.0",
31
- "yaml": "^2.0.0"
34
+ "yaml": "^2.0.0",
35
+ "axios": "^1.0.0"
32
36
  },
33
37
  "devDependencies": {
34
38
  "typescript": "^5.0.0",
35
- "copyfiles": "^2.4.1"
39
+ "copyfiles": "^2.4.1",
40
+ "@types/node": "^20.0.0",
41
+ "@types/fs-extra": "^11.0.0"
36
42
  }
37
43
  }
package/readme.md CHANGED
@@ -1,48 +1,119 @@
1
1
  # koishi-plugin-game-mini
2
2
 
3
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
4
+ [![Koishi Version](https://img.shields.io/badge/Koishi-%3E%3D4.0.0-brightgreen.svg)](https://koishi.chat/)
5
+
3
6
  ## 项目介绍 (Project Introduction)
4
7
 
5
8
  ### 中文
6
- 这是一款为 Koishi 聊天机器人框架开发的轻量级猜数字小游戏插件,核心玩法贴合经典“终极密码”规则,兼具易用性与可配置性:
7
- - 支持自定义猜数字的数值范围(默认 0-100
8
- - 区分群聊/私聊模式:私聊时 Bot 强制参与,群聊可通过配置开关控制 Bot 是否参与
9
+ 这是一款为 Koishi 聊天机器人框架开发的轻量级多功能小游戏插件,包含经典猜数字、猜王者荣耀英雄、看图猜成语、成语接龙四款趣味游戏,兼具易用性与可配置性:
10
+ - **猜数字**:支持自定义数值范围(默认 0-100),区分群聊/私聊模式控制 Bot 参与状态
11
+ - **猜王者英雄**:基于诗词/提示猜王者荣耀英雄,支持简单/中等/困难三种难度
12
+ - **看图猜成语**:根据图片和备选字猜成语,支持提示功能和切换题目
13
+ - **成语接龙**:与 Bot 进行成语接龙对战,自动返回成语拼音和释义
9
14
 
10
15
  ### English
11
- This is a lightweight number guessing game plugin developed for the Koishi chatbot framework, with core gameplay adhering to the classic "Ultimate Password" rules and both ease of use and configurability:
12
- - Supports customizable number range for guessing (default 0-100)
13
- - Differentiates between group chat and private chat modes: Bots are forced to participate in private chats, while bot participation in group chats can be controlled via configuration switch
16
+ This is a lightweight multi-functional game plugin developed for the Koishi chatbot framework, including four fun games: classic number guessing, King of Glory hero guessing, idiom guessing from pictures, and idiom solitaire, with both ease of use and configurability:
17
+ - **Number Guessing**: Supports customizable number range (default 0-100), controls Bot participation status by distinguishing group chat/private chat modes
18
+ - **King of Glory Hero Guessing**: Guess King of Glory heroes based on poems/hints, supports three difficulty levels: easy/medium/hard
19
+ - **Idiom Guessing from Pictures**: Guess idioms based on pictures and candidate characters, supports hint function and question switching
20
+ - **Idiom Solitaire**: Compete with Bot in idiom solitaire, automatically return pinyin and meaning of idioms
14
21
 
15
22
  ## 使用说明 (Usage)
16
23
 
17
24
  ### 中文
18
25
  | 命令 (Command) | 功能说明 (Description) |
19
26
  | --- | --- |
20
- | `guess start` | 启动猜数字游戏,初始范围为配置的最小值-最大值;若 Bot 配置参与,会先随机猜一个数字 |
27
+ | **猜数字游戏** | |
28
+ | `guess start` | 启动猜数字游戏,初始范围为配置的最小值-最大值 |
21
29
  | 直接输入数字 | 游戏运行时输入纯数字即可猜测,系统会实时提示“猜大了/猜小了”并缩小范围,或提示“猜对了”并结束游戏 |
22
30
  | `guess stop` | 停止当前猜数字游戏,并公布正确数字 |
31
+ | **王者英雄猜谜** | |
32
+ | `wzhero start <难度>` | 启动王者英雄猜谜游戏,难度可选:简单/中等/困难 |
33
+ | 输入英雄名称 | 游戏运行时输入英雄名猜测答案,系统会返回结果提示 |
34
+ | 输入“提示” | 获取当前英雄的线索提示(有次数限制) |
35
+ | `wzhero stop` | 停止当前王者英雄猜谜游戏 |
36
+ | **看图猜成语** | |
37
+ | `cyimage start` | 启动看图猜成语游戏,获取初始题目和图片链接 |
38
+ | 输入成语 | 游戏运行时输入猜测的成语答案 |
39
+ | 输入“提示 [等级]” | 获取当前题目的提示(等级1-5,默认1级) |
40
+ | 输入“下一题” | 切换到下一个猜成语题目 |
41
+ | `cyimage stop` | 停止当前看图猜成语游戏 |
42
+ | **成语接龙** | |
43
+ | `cyjl start` | 启动成语接龙游戏,Bot 先出第一个成语 |
44
+ | 输入“我接<成语>” | 接Bot的成语进行接龙(如:我接一帆风顺) |
45
+ | `cyjl stop` | 停止当前成语接龙游戏 |
23
46
 
24
47
  ### English
25
48
  | Command | Description |
26
49
  | --- | --- |
27
- | `guess start` | Start the number guessing game with the initial range of configured min-max values; if the Bot is configured to participate, it will randomly guess a number first |
50
+ | **Number Guessing Game** | |
51
+ | `guess start` | Start the number guessing game with the initial range of configured min-max values |
28
52
  | Enter number directly | Enter a pure number during the game to guess; the system will prompt "too big/too small" in real time and narrow the range, or prompt "correct" and end the game |
29
53
  | `guess stop` | Stop the current number guessing game and announce the correct number |
54
+ | **King of Glory Hero Guessing** | |
55
+ | `wzhero start <difficulty>` | Start the King of Glory hero guessing game, difficulty options: easy/medium/hard |
56
+ | Enter hero name | Enter the hero name to guess the answer during the game, the system will return result prompts |
57
+ | Enter "提示" | Get clue hints for the current hero (limited times) |
58
+ | `wzhero stop` | Stop the current King of Glory hero guessing game |
59
+ | **Idiom Guessing from Pictures** | |
60
+ | `cyimage start` | Start the idiom guessing game from pictures, get initial question and image link |
61
+ | Enter idiom | Enter the guessed idiom answer during the game |
62
+ | Enter "提示 [level]" | Get hints for the current question (level 1-5, default level 1) |
63
+ | Enter "下一题" | Switch to the next idiom guessing question |
64
+ | `cyimage stop` | Stop the current idiom guessing game from pictures |
65
+ | **Idiom Solitaire** | |
66
+ | `cyjl start` | Start the idiom solitaire game, Bot will give the first idiom |
67
+ | Enter "我接<idiom>" | Respond to Bot's idiom for solitaire (e.g.: 我接一帆风顺) |
68
+ | `cyjl stop` | Stop the current idiom solitaire game |
30
69
 
31
70
  ## 配置说明 (Configuration)
32
71
 
33
72
  ### 中文
34
73
  | 配置项 (Config Item) | 说明 (Description) | 默认值 (Default) |
35
74
  | --- | --- | --- |
75
+ | **基础功能开关** | | |
76
+ | `enableNumberGuess` | 是否开启猜数字游戏功能 | true |
77
+ | `enableWzHero` | 是否开启王者英雄猜谜游戏功能 | true |
78
+ | `enableChengyuImage` | 是否开启看图猜成语游戏功能 | true |
79
+ | `enableChengyuJielong` | 是否开启成语接龙游戏功能 | true |
80
+ | **猜数字配置** | | |
36
81
  | `guessNumber.min` | 猜数字最小值 | 0 |
37
82
  | `guessNumber.max` | 猜数字最大值 | 100 |
38
83
  | `guessNumber.botParticipateInGroup` | 群聊中 Bot 是否参与猜数字(私聊场景下 Bot 强制参与) | true |
84
+ | **王者英雄猜谜配置** | | |
85
+ | `wzHero.botParticipateInGroup` | 群聊中 Bot 是否参与王者英雄猜谜(私聊场景下 Bot 强制参与) | true |
86
+ | **看图猜成语配置** | | |
87
+ | `chengyuImage.botParticipateInGroup` | 群聊中 Bot 是否参与看图猜成语(私聊场景下 Bot 强制参与) | true |
88
+ | **成语接龙配置** | | |
89
+ | `chengyuJielong.botParticipateInGroup` | 群聊中 Bot 是否参与成语接龙(私聊场景下 Bot 强制参与) | true |
90
+ | **API配置** | | |
91
+ | `apiConfig.wzHeroUserId` | 王者英雄猜谜API的用户区分ID | 1828222534 |
92
+ | `apiConfig.cyjlUserId` | 成语接龙API的用户区分ID | 1828222534 |
93
+ | `apiConfig.timeout` | 第三方API请求超时时间(毫秒) | 5000 |
39
94
 
40
95
  ### English
41
96
  | Config Item | Description | Default |
42
97
  | --- | --- | --- |
43
- | `guessNumber.min` | Minimum value for number guessing| 0 |
98
+ | **Basic Function Switch** | | |
99
+ | `enableNumberGuess` | Whether to enable the number guessing game function | true |
100
+ | `enableWzHero` | Whether to enable the King of Glory hero guessing game function | true |
101
+ | `enableChengyuImage` | Whether to enable the idiom guessing from pictures game function | true |
102
+ | `enableChengyuJielong` | Whether to enable the idiom solitaire game function | true |
103
+ | **Number Guessing Configuration** | | |
104
+ | `guessNumber.min` | Minimum value for number guessing | 0 |
44
105
  | `guessNumber.max` | Maximum value for number guessing | 100 |
45
106
  | `guessNumber.botParticipateInGroup` | Whether the Bot participates in number guessing in group chats (Bot is forced to participate in private chat scenarios) | true |
107
+ | **King of Glory Hero Guessing Configuration** | | |
108
+ | `wzHero.botParticipateInGroup` | Whether the Bot participates in King of Glory hero guessing in group chats (Bot is forced to participate in private chat scenarios) | true |
109
+ | **Idiom Guessing from Pictures Configuration** | | |
110
+ | `chengyuImage.botParticipateInGroup` | Whether the Bot participates in idiom guessing from pictures in group chats (Bot is forced to participate in private chat scenarios) | true |
111
+ | **Idiom Solitaire Configuration** | | |
112
+ | `chengyuJielong.botParticipateInGroup` | Whether the Bot participates in idiom solitaire in group chats (Bot is forced to participate in private chat scenarios) | true |
113
+ | **API Configuration** | | |
114
+ | `apiConfig.wzHeroUserId` | User ID for King of Glory hero guessing API | 1828222534 |
115
+ | `apiConfig.cyjlUserId` | User ID for idiom solitaire API | 1828222534 |
116
+ | `apiConfig.timeout` | Timeout time for third-party API requests (milliseconds) | 5000 |
46
117
 
47
118
  ## 项目贡献者 (Contributors)
48
119
  | 贡献者 (Contributor) | 贡献内容 (Contribution) |
@@ -58,9 +129,4 @@ This project is licensed under the MIT Open Source License. You are free to use,
58
129
  ## 支持我们 (Support Us)
59
130
  如果这个项目对您有帮助,欢迎点亮仓库右上角的 Star ⭐ 支持我们,这将是对所有贡献者最大的鼓励!
60
131
 
61
- If this project is helpful to you, please feel free to star the repository in the upper right corner ⭐ to support us, which will be the greatest encouragement to all contributors!
62
-
63
- ## 问题反馈 (Feedback)
64
- 如有使用问题、功能建议或 Bug 反馈,可通过 GitHub Issues 提交,我们会尽快响应。
65
-
66
- If you have any questions or suggestions, please submit them via GitHub Issues, and we will respond as soon as possible.
132
+ If this project is helpful to you, please feel free to star the repository in the upper right corner ⭐ to support us, which will be the greatest encouragement to all contributors!