{"_id":"@dgck81lnn/koishi-plugin-auto-delete-response","_rev":"2-57819cdc539f524402821bb44c492f10","name":"@dgck81lnn/koishi-plugin-auto-delete-response","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@dgck81lnn/koishi-plugin-auto-delete-response","version":"0.1.0","keywords":["chatbot","koishi","plugin"],"license":"MIT","_id":"@dgck81lnn/koishi-plugin-auto-delete-response@0.1.0","maintainers":[{"name":"dgck81lnn","email":"triluolnn@163.com"}],"homepage":"https://github.com/DGCK81LNN/koishi-plugin-auto-delete-response","dist":{"shasum":"030bf7bc5259971ab09d8c7e6f4eb52ef1783eea","tarball":"https://registry.npmjs.org/@dgck81lnn/koishi-plugin-auto-delete-response/-/koishi-plugin-auto-delete-response-0.1.0.tgz","fileCount":4,"integrity":"sha512-MuUr8XSw4h/QSayYbtEyMvc+nXmax4e4P2bTPDR70W3p5vnC3qizJoEkuTwC5nbfE2m7v6mJL35RZYKKExvy0w==","signatures":[{"sig":"MEUCIAdrctb8ckqORfYoXuYI6jHu/V0dGiEtRJM7DXpYOJBJAiEAtcMs8VBI1Dst47oYBTiV+sIEf+dPPwblGYgLSGnmwYU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4064},"main":"lib/index.js","koishi":{"services":{"implements":["autoDeletedResponse"]}},"gitHead":"4d79c454ec3a6496690676f95f05181eaff5b537","typings":"lib/index.d.ts","_npmUser":{"name":"dgck81lnn","email":"triluolnn@163.com"},"repository":{"url":"git+https://github.com/DGCK81LNN/koishi-plugin-auto-delete-response.git","type":"git"},"description":"Auto deleted responses service for Koishi","directories":{},"_hasShrinkwrap":false,"peerDependencies":{"koishi":"^4.17.8"},"_npmOperationalInternal":{"tmp":"tmp/koishi-plugin-auto-delete-response_0.1.0_1722240264030_0.582234927134992","host":"s3://npm-registry-packages"}},"0.2.0":{"name":"@dgck81lnn/koishi-plugin-auto-delete-response","description":"Auto deleted responses service for Koishi","version":"0.2.0","main":"lib/index.js","typings":"lib/index.d.ts","license":"MIT","homepage":"https://github.com/DGCK81LNN/koishi-plugin-auto-delete-response","repository":{"type":"git","url":"git+https://github.com/DGCK81LNN/koishi-plugin-auto-delete-response.git"},"keywords":["chatbot","koishi","plugin"],"koishi":{"services":{"implements":["autoDeletedResponse"]}},"peerDependencies":{"koishi":"^4.17.8"},"_id":"@dgck81lnn/koishi-plugin-auto-delete-response@0.2.0","gitHead":"cae42804c63a7847e9bf62d8e4f6f071c46de4d1","bugs":{"url":"https://github.com/DGCK81LNN/koishi-plugin-auto-delete-response/issues"},"_nodeVersion":"22.9.0","_npmVersion":"11.3.0","dist":{"integrity":"sha512-043ZrBYOyTwSw7n9m1jMtgS+b8IegpduFgGAmtoTSjyxKxXA1cgcefs3ZcIed7LFzoZ2/CyIUOMcTwifluU2UA==","shasum":"b292bdeec8fe825130823348643e57338bae0126","tarball":"https://registry.npmjs.org/@dgck81lnn/koishi-plugin-auto-delete-response/-/koishi-plugin-auto-delete-response-0.2.0.tgz","fileCount":4,"unpackedSize":9059,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDb3Cn0GmRS3I48nxGqBsXvh6CF4uSIDr/kLmuQsuAvggIgNXW95cA3P2/HrbV7h0bwK2inKRk4BaTPq914MwFQ9Oc="}]},"_npmUser":{"name":"dgck81lnn","email":"triluolnn@163.com"},"directories":{},"maintainers":[{"name":"dgck81lnn","email":"triluolnn@163.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/koishi-plugin-auto-delete-response_0.2.0_1747734343840_0.9927647570560145"},"_hasShrinkwrap":false}},"time":{"created":"2024-07-29T08:04:23.935Z","modified":"2025-05-20T09:45:44.172Z","0.1.0":"2024-07-29T08:04:24.163Z","0.2.0":"2025-05-20T09:45:44.022Z"},"license":"MIT","homepage":"https://github.com/DGCK81LNN/koishi-plugin-auto-delete-response","keywords":["chatbot","koishi","plugin"],"repository":{"type":"git","url":"git+https://github.com/DGCK81LNN/koishi-plugin-auto-delete-response.git"},"description":"Auto deleted responses service for Koishi","maintainers":[{"name":"dgck81lnn","email":"triluolnn@163.com"}],"readme":"# @dgck81lnn/koishi-plugin-auto-delete-response\n\n[![npm](https://img.shields.io/npm/v/@dgck81lnn/koishi-plugin-auto-delete-response?style=flat-square)](https://www.npmjs.com/package/koishi-plugin-auto-delete-response)\n\n本插件提供了一个 `autoDeleteResponse` 服务，使用该服务代替 `session.send()` 发送消息，可使机器人在用户的消息被删除（撤回）时自动删除（撤回）发出的响应消息。\n\n## 配置\n\n### `timeout`\n\n通过 `autoDeleteResponse.send()` 发送响应及本插件的上下文过滤器内任何消息被删除的记录的时间限制，单位为毫秒。\n\n## 用法\n\n### `ctx.autoDeleteResponse.send(session: Session, fragment: Element.Fragment, options?: Universal.SendOptions): Promise<string[]>`\n\n替代 `session.send(fragment, options)` 使用。当引发本会话的消息被用户删除时，机器人会自动删除对应的所有通过此方法发出的消息。若调用本方法时，引发本会话的消息已在近期被删除，则会自动放弃发送。\n\n### `ctx.autoDeleteResponse.action(action: Command.Action): Command.Action`\n\n用于包装指令的 `action` 回调函数。若本次指令调用为根调用（`argv.root` 为真；本次指令调用是由消息会话直接引发，而非通过 `session.execute()` 手动发起），则会将 `action` 的返回值（或抛出的 `SessionError`）用 `autoDeleteResponse.send()` 发送。目前不会处理 `SessionError` 以外的异常，因此“发生未知错误”的提示信息并不会被自动撤回。\n\n## 示例\n\n1.  ~~~javascript\n    ctx.middleware(async (session, next) => {\n      if (session.content === \"天王盖地虎\") {\n        await ctx.sleep(5000)\n        ctx.autoDeleteResponse.send(session, \"宝塔镇河妖\")\n        return\n      }\n      return next()\n    })\n    ~~~\n\n    收到“天王盖地虎”时，机器人延迟 5 秒后通过本服务回复“宝塔镇河妖”。若在发送前 `timeout` 时间内用户撤回了这条“天王盖地虎”，则这次 `ctx.autoDeleteResponse.send()` 将会失效，“宝塔镇河妖”不会实际发送出去；若在“宝塔镇河妖”发送后 `timeout` 时间内用户撤回这条“天王盖地虎”，则机器人也会撤回“宝塔镇河妖”。\n\n2.  ~~~javascript\n    ctx.command(\"echo <text:text>\")\n      .action(ctx.autoDeleteResponse.action(({ session }, text) => {\n        if (!text) throw new SessionError(\".expect-text\")\n        return h.text(text)\n      }))\n\n    ctx.i18n.define(\"zh-CN\", \"commands.echo\", {\n      description: \"输出给定文本\",\n      messages: {\n        \"expect-text\": \"缺少文本。\",\n      },\n    })\n    ~~~\n\n    一个简单的 echo 指令，当用户撤回指令消息时，使机器人也撤回响应。但若用户使用插值语法（如 `other-command $(echo text)`）等方法间接调用该指令，则不会触发该机制。\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DGCK81LNN/koishi-plugin-auto-delete-response/issues"}}