koishi-plugin-wordle-game 2.2.2 → 2.2.3

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
@@ -21,6 +21,7 @@ export interface Config {
21
21
  shouldPromptForWordLengthOnNonClassicStart: boolean;
22
22
  enableWordGuessTimeLimit: boolean;
23
23
  wordGuessTimeLimitInSeconds: number;
24
+ retractDelay: number;
24
25
  imageType: "png" | "jpeg" | "webp";
25
26
  isTextToImageConversionEnabled: boolean;
26
27
  }
package/lib/index.js CHANGED
@@ -141,6 +141,7 @@ exports.Config = koishi_1.Schema.intersect([
141
141
  koishi_1.Schema.object({}),
142
142
  ]),
143
143
  koishi_1.Schema.object({
144
+ retractDelay: koishi_1.Schema.number().min(0).default(0).description(`自动撤回等待的时间,单位是秒。值为 0 时不启用自动撤回功能。`),
144
145
  imageType: koishi_1.Schema.union(['png', 'jpeg', 'webp']).default('png').description(`发送的图片类型。`),
145
146
  isTextToImageConversionEnabled: koishi_1.Schema.boolean().default(false).description(`是否开启将文本转为图片的功能(可选),如需启用,需要启用 \`markdownToImage\` 服务。`),
146
147
  }),
@@ -2657,7 +2658,10 @@ ${gridHtml}
2657
2658
  }
2658
2659
  }
2659
2660
  // csh*
2661
+ let sentMessages = [];
2660
2662
  async function sendMessage(session, message) {
2663
+ const { bot, channelId } = session;
2664
+ let messageId;
2661
2665
  if (config.isTextToImageConversionEnabled) {
2662
2666
  const lines = message.split('\n');
2663
2667
  const isOnlyImgTag = lines.length === 1 && lines[0].trim().startsWith('<img');
@@ -2676,11 +2680,20 @@ ${gridHtml}
2676
2680
  })
2677
2681
  .join('\n');
2678
2682
  const imageBuffer = await ctx.markdownToImage.convertToImage(modifiedMessage);
2679
- await session.send(koishi_1.h.image(imageBuffer, 'image/png'));
2683
+ [messageId] = await session.send(koishi_1.h.image(imageBuffer, `image/${config.imageType}`));
2680
2684
  }
2681
2685
  }
2682
2686
  else {
2683
- await session.send(message);
2687
+ [messageId] = await session.send(message);
2688
+ }
2689
+ if (config.retractDelay === 0)
2690
+ return;
2691
+ sentMessages.push(messageId);
2692
+ if (sentMessages.length > 1) {
2693
+ const oldestMessageId = sentMessages.shift();
2694
+ setTimeout(async () => {
2695
+ await bot.deleteMessage(channelId, oldestMessageId);
2696
+ }, config.retractDelay * 1000);
2684
2697
  }
2685
2698
  }
2686
2699
  async function sendPostRequestForGPT1106(content) {
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.2.2",
4
+ "version": "2.2.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
package/readme.md CHANGED
@@ -95,6 +95,7 @@ npm install koishi-plugin-wordle-game
95
95
  - 是否开启猜单词游戏作答时间限制功能。默认值为 `false`.
96
96
  - `wordGuessTimeLimitInSeconds: number`
97
97
  - 猜单词游戏作答时间,单位是秒。默认值为 `120`.
98
+ - `retractDelay`:自动撤回等待的时间,默认值为 0,单位是秒。值为 0 时不启用自动撤回功能。
98
99
  - `imageType: "png" | "jpeg" | "webp"`
99
100
  - 发送的图片类型。默认值为 `"png"`.
100
101
  - `isTextToImageConversionEnabled: boolean`
@@ -220,6 +221,7 @@ npm install koishi-plugin-wordle-game
220
221
  - [百度汉语](https://hanyu.baidu.com/) - 查找成语
221
222
  - [WordFinder](https://wordword.org/) - 单词查找
222
223
  - [Numberle](https://dduarte.github.io/numberle/) - 数字猜测游戏
224
+ - [词影](https://cy.surprising.studio/) - 词影游戏代码与样式
223
225
  - [Numberle](https://numberle.org/) - 数学方程式猜测游戏
224
226
  - [LewdleGame](https://www.lewdlegame.com/App) - Lewdle 模式单词列表
225
227
  - [WordlePlay](https://wordleplay.com/wordle-games) - 拓展玩法/单词列表补充
@@ -228,7 +230,6 @@ npm install koishi-plugin-wordle-game
228
230
  - [koishi-plugin-wordle](https://www.npmjs.com/package/koishi-plugin-wordle) - Wordle 经典模式词典
229
231
  - [nonebot-plugin-wordle](https://github.com/noneplugin/nonebot-plugin-wordle) - Nonebot Wordle 的词典
230
232
  - [Wordle 2315 words list](https://gist.github.com/DevilXD/6ad6cc1fe37872d069a795edd51233b2#file-wordle_words-txt) - 经典 Wordle 的单词列表
231
- - [词影](https://cy.surprising.studio/) - 词影游戏代码与样式
232
233
 
233
234
  ## ✨ License
234
235