koishi-plugin-echo-cave 1.25.1 → 1.25.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.
Files changed (2) hide show
  1. package/lib/index.cjs +4 -7
  2. package/package.json +1 -1
package/lib/index.cjs CHANGED
@@ -94,16 +94,13 @@ function parseUserIds(userIds) {
94
94
 
95
95
  // src/utils/msg/message-listener.ts
96
96
  async function listenForUserMessage(ctx, session, prompt, timeout, onMessage, onTimeout) {
97
- const userId = session.userId;
98
- const channelId = session.channelId;
97
+ const { userId, channelId } = session;
99
98
  const promptMessageId = await session.onebot.sendGroupMsg(channelId, prompt);
100
- let timeoutId;
101
99
  const listener = async (msgSession) => {
102
100
  if (msgSession.userId === userId && msgSession.channelId === channelId) {
103
- clearTimeout(timeoutId);
104
101
  const shouldContinue = await onMessage(msgSession.content);
105
102
  if (!shouldContinue) {
106
- ctx.off("message", listener);
103
+ cancelListener();
107
104
  try {
108
105
  await session.onebot.deleteMsg(promptMessageId);
109
106
  } catch (error) {
@@ -112,9 +109,9 @@ async function listenForUserMessage(ctx, session, prompt, timeout, onMessage, on
112
109
  }
113
110
  }
114
111
  };
115
- ctx.on("message", listener);
112
+ const cancelListener = ctx.on("message", listener);
116
113
  const cancelTimeout = ctx.setTimeout(async () => {
117
- ctx.off("message", listener);
114
+ cancelListener();
118
115
  if (onTimeout) {
119
116
  await onTimeout();
120
117
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-echo-cave",
3
3
  "description": "Group echo cave",
4
- "version": "1.25.1",
4
+ "version": "1.25.2",
5
5
  "main": "lib/index.cjs",
6
6
  "typings": "lib/index.d.ts",
7
7
  "type": "module",