node-karin 1.15.1 → 1.15.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # 更新日志
2
2
 
3
+ ## [1.15.2](https://github.com/KarinJS/Karin/compare/core-v1.15.1...core-v1.15.2) (2026-03-30)
4
+
5
+
6
+ ### 🐛 Bug Fixes
7
+
8
+ * 上下文(ctx)方法添加 `超时后是否抛出错误` 选项,默认 true ([#634](https://github.com/KarinJS/Karin/issues/634)) ([9f2ac76](https://github.com/KarinJS/Karin/commit/9f2ac7679770878495825e7d450fff31857a9c51))
9
+
3
10
  ## [1.15.1](https://github.com/KarinJS/Karin/compare/core-v1.15.0...core-v1.15.1) (2026-03-24)
4
11
 
5
12
 
package/dist/index.d.ts CHANGED
@@ -7499,7 +7499,9 @@ declare const ctx: <T = Message>(e: Event, options?: {
7499
7499
  reply?: boolean;
7500
7500
  /** 超时回复文本 默认为'操作超时已取消' */
7501
7501
  replyMsg?: string;
7502
- }) => Promise<T>;
7502
+ /** 超时后是否抛出错误 默认为 true */
7503
+ throwOnTimeout?: boolean;
7504
+ }) => Promise<T | null>;
7503
7505
 
7504
7506
  interface HandlerOptions {
7505
7507
  /** 插件名称 */
package/dist/index.mjs CHANGED
@@ -24237,8 +24237,8 @@ var command = (reg, second, options = {}) => {
24237
24237
  init_internal();
24238
24238
  init_context();
24239
24239
  var ctx2 = async (e, options) => {
24240
- const time2 = options?.time || 120;
24241
- const userId = options?.userId || e.userId || e.user_id;
24240
+ const { time: time2 = 120, userId: optionUserId, reply: reply2, replyMsg, throwOnTimeout = true } = options ?? {};
24241
+ const userId = optionUserId || e.userId || e.user_id;
24242
24242
  const key = e.contact.subPeer ? `${e.contact.peer}:${e.contact.subPeer}:${userId}` : `${e.contact.peer}:${userId}`;
24243
24243
  ctx.set(key, e);
24244
24244
  return new Promise((resolve, reject) => {
@@ -24246,9 +24246,14 @@ var ctx2 = async (e, options) => {
24246
24246
  const data = ctx.get(key);
24247
24247
  if (data?.eventId === e.eventId) {
24248
24248
  ctx.delete(key);
24249
- if (options?.reply) e.reply(options.replyMsg || "\u64CD\u4F5C\u8D85\u65F6\u5DF2\u53D6\u6D88");
24249
+ if (reply2) e.reply(replyMsg || "\u64CD\u4F5C\u8D85\u65F6\u5DF2\u53D6\u6D88");
24250
24250
  listeners.removeAllListeners(`ctx:${key}`);
24251
- reject(new Error(`\u63A5\u6536\u4E0B\u6587\u4E8B\u4EF6\u8D85\u65F6\uFF0C\u5DF2\u53D6\u6D88\u4E0B\u6587\u76D1\u542C: ${key}`));
24251
+ if (throwOnTimeout) {
24252
+ reject(new Error(`\u63A5\u6536\u4E0B\u6587\u4E8B\u4EF6\u8D85\u65F6\uFF0C\u5DF2\u53D6\u6D88\u4E0B\u6587\u76D1\u542C: ${key}`));
24253
+ } else {
24254
+ logger.debug(`\u63A5\u6536\u4E0B\u6587\u4E8B\u4EF6\u8D85\u65F6\uFF0C\u5DF2\u53D6\u6D88\u4E0B\u6587\u76D1\u542C: ${key}`);
24255
+ resolve(null);
24256
+ }
24252
24257
  return true;
24253
24258
  }
24254
24259
  }, time2 * 1e3);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "1.15.1",
3
+ "version": "1.15.2",
4
4
  "description": "Lightweight, efficient, concise, and stable robot framework.",
5
5
  "keywords": [
6
6
  "node",