koishi-plugin-wordle-game 2.1.5 → 2.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.
Files changed (2) hide show
  1. package/lib/index.js +20 -8
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -24,7 +24,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  return result;
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.apply = exports.Config = exports.usage = exports.name = exports.inject = void 0;
27
+ exports.Config = exports.usage = exports.name = exports.inject = void 0;
28
+ exports.apply = apply;
28
29
  const koishi_1 = require("koishi");
29
30
  // import {} from 'koishi-plugin-rr-gpt'
30
31
  const cheerio_1 = require("cheerio");
@@ -960,7 +961,6 @@ async function apply(ctx, config) {
960
961
  // 玩家记录输
961
962
  await updatePlayerRecordsLose(channelId, gameInfo);
962
963
  await endGame(channelId);
963
- await setGuessRunningStatus(channelId, false);
964
964
  return await sendMessage(session, `【@${username}】\n作答时间超过【${config.wordGuessTimeLimitInSeconds}】秒!\n很遗憾,你们输了!\n下次猜快点吧~`);
965
965
  // return await sendMessage(session, `【@${username}】\n作答时间超过【${config.wordGuessTimeLimitInSeconds}】秒!\n很遗憾,你们输了!\n下次猜快点吧~\n${h.image(imageBuffer, `image/${config.imageType}`)}`)
966
966
  }
@@ -985,12 +985,15 @@ async function apply(ctx, config) {
985
985
  return await sendMessage(session, `【@${username}】\n输入包含非字母字符,请重新输入!`);
986
986
  }
987
987
  if (!isFourCharacterIdiom(inputWord) && gameMode === '汉兜' || !isFourCharacterIdiom(inputWord) && gameMode === '词影') {
988
+ await setGuessRunningStatus(channelId, false);
988
989
  return await sendMessage(session, `【@${username}】\n您确定您输入的是四字词语吗?`);
989
990
  }
990
991
  if (gameMode === 'Numberle' && !isNumericString(inputWord)) {
992
+ await setGuessRunningStatus(channelId, false);
991
993
  return await sendMessage(session, `【@${username}】\n您确定您输入的是 ${guessWordLength} 长度的数字吗?`);
992
994
  }
993
995
  if (gameMode === 'Math' && !isMathEquationValid(inputWord)) {
996
+ await setGuessRunningStatus(channelId, false);
994
997
  return await sendMessage(session, `【@${username}】\n请使用+-*/=运算符和0-9之间的数字!\n并组成正确的数学方程式!`);
995
998
  }
996
999
  if (inputWord.length !== gameInfo.guessWordLength && gameMode !== '汉兜' && gameMode !== '词影' && gameMode !== 'Numberle' && gameMode !== 'Math') {
@@ -1825,7 +1828,9 @@ ${rankType3.map((type, index) => `${index + 1}. ${type}`).join('\n')}
1825
1828
  });
1826
1829
  // ch*
1827
1830
  async function generateHandlePinyinsImage(pinyinsHtml) {
1828
- const page = await ctx.puppeteer.page();
1831
+ const browser = ctx.puppeteer.browser;
1832
+ const context = await browser.createBrowserContext();
1833
+ const page = await context.newPage();
1829
1834
  await page.setViewport({ width: 420, height: 570, deviceScaleFactor: 1 });
1830
1835
  const filePath = path.join(__dirname, 'emptyHtml.html').replace(/\\/g, '/');
1831
1836
  await page.goto('file://' + filePath);
@@ -1904,7 +1909,9 @@ ${rankType3.map((type, index) => `${index + 1}. ${type}`).join('\n')}
1904
1909
  return resultStrings.join('\n');
1905
1910
  }
1906
1911
  async function generateWordlesImage(htmlImgString) {
1907
- const page = await ctx.puppeteer.page();
1912
+ const browser = ctx.puppeteer.browser;
1913
+ const context = await browser.createBrowserContext();
1914
+ const page = await context.newPage();
1908
1915
  await page.setViewport({
1909
1916
  width: config.compositeImagePageWidth,
1910
1917
  height: config.compositeImagePageHeight,
@@ -2477,7 +2484,9 @@ ${rankType3.map((type, index) => `${index + 1}. ${type}`).join('\n')}
2477
2484
  }
2478
2485
  }
2479
2486
  async function generateImage(styledHtml, gridHtml) {
2480
- const page = await ctx.puppeteer.page();
2487
+ const browser = ctx.puppeteer.browser;
2488
+ const context = await browser.createBrowserContext();
2489
+ const page = await context.newPage();
2481
2490
  await page.setViewport({ width: 611, height: 731, deviceScaleFactor: 1 });
2482
2491
  const filePath = path.join(__dirname, 'emptyHtml.html').replace(/\\/g, '/');
2483
2492
  await page.goto('file://' + filePath);
@@ -2494,7 +2503,9 @@ ${rankType3.map((type, index) => `${index + 1}. ${type}`).join('\n')}
2494
2503
  return imageBuffer;
2495
2504
  }
2496
2505
  async function generateImageForCiying(gridHtml, rowNum) {
2497
- const page = await ctx.puppeteer.page();
2506
+ const browser = ctx.puppeteer.browser;
2507
+ const context = await browser.createBrowserContext();
2508
+ const page = await context.newPage();
2498
2509
  await page.setViewport({ width: 611, height: 140 * rowNum, deviceScaleFactor: 1 });
2499
2510
  const filePath = path.join(__dirname, 'emptyHtml.html').replace(/\\/g, '/');
2500
2511
  await page.goto('file://' + filePath);
@@ -2536,7 +2547,9 @@ ${gridHtml}
2536
2547
  return imageBuffer;
2537
2548
  }
2538
2549
  async function generateImageForHandle(gridHtml) {
2539
- const page = await ctx.puppeteer.page();
2550
+ const browser = ctx.puppeteer.browser;
2551
+ const context = await browser.createBrowserContext();
2552
+ const page = await context.newPage();
2540
2553
  await page.setViewport({ width: 611, height: 731, deviceScaleFactor: 1 });
2541
2554
  const filePath = path.join(__dirname, 'emptyHtml.html').replace(/\\/g, '/');
2542
2555
  await page.goto('file://' + filePath);
@@ -4482,4 +4495,3 @@ ${content}
4482
4495
  </div>`;
4483
4496
  // apply
4484
4497
  }
4485
- exports.apply = apply;
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.1.5",
4
+ "version": "2.1.7",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [