{"id":24013320,"url":"https://github.com/fi6/kbotify","last_synced_at":"2025-10-08T12:07:13.816Z","repository":{"id":41831282,"uuid":"328973543","full_name":"fi6/kBotify","owner":"fi6","description":"开黑啦TypeScript/JavaScript开发框架，几行代码即可制作机器人。包含全部官方API，添加了多个便利的方法，让开发者用尽可能短的代码完成用户交互功能。","archived":false,"fork":false,"pushed_at":"2022-11-05T12:29:26.000Z","size":676,"stargazers_count":36,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-22T13:33:32.103Z","etag":null,"topics":["bot","javascript","kaiheila","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fi6.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-12T12:02:45.000Z","updated_at":"2024-04-25T01:28:07.000Z","dependencies_parsed_at":"2022-09-20T03:54:24.330Z","dependency_job_id":null,"html_url":"https://github.com/fi6/kBotify","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fi6%2FkBotify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fi6%2FkBotify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fi6%2FkBotify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fi6%2FkBotify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fi6","download_url":"https://codeload.github.com/fi6/kBotify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249047348,"owners_count":21204236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","javascript","kaiheila","typescript"],"created_at":"2025-01-08T06:53:00.882Z","updated_at":"2025-10-08T12:07:08.785Z","avatar_url":"https://github.com/fi6.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kBotify\n\n[![npm version](https://badge.fury.io/js/kbotify.svg)](https://www.npmjs.com/package/kbotify)\n\n基于 [BotRoot](https://github.com/shugen002/BotRoot) 的 JavaScript / TypeScript 开黑啦 Bot 开发框架。\n\n## 优势\n\n-   强大的交互功能，让你轻松完成各种需要大量交互的复杂功能。\n-   完善的 API，稳定的迭代，让你专注开发，无需操心 SDK。\n-   同时拥有 SDK 与命令框架模式，一行代码也能写 Bot。\n\n## 快速开始\n\n### 一个简单的示例\n\n```ts\nimport { KBotify } from 'kbotify';\n\nconst bot = new KBotify({\n    mode: 'webhook', // Webhook 模式\n    port: 12345, // 回调监听端口\n    token: 'your token',\n    verifyToken: 'your verify token',\n    key: 'your encrypt key',\n    ignoreDecryptError: false, // 是否忽略消息解密错误 如果需要可以改为true\n});\n\nbot.connect(); // 启动 Bot\n```\n\n### 从模板开始\n\n你也可以使用[仓库模板](https://github.com/fi6/kBotify-template)  \n参考其中的 src/commands/echo 文件夹即可。修改 src/configs 文件夹下 template-auth.ts 中的内容，并重命名为 auth.ts 即可开始使用。  \n可参考[文档链接](https://fi6.github.io/kBotify/)\n\n## TODO\n\n-   [x] 文档\n-   [x] 精简不必要的代码\n-   [ ] 自动生成 Menu\n-   [ ] 增加命令速率限制（全局，服务器，频道，角色，用户）\n-   [ ] session 增加 context\n-   [ ] 增加匹配模式：命令匹配/前缀匹配（如：直接匹配 .房间 创建，而不是先匹配.房间再匹配创建）\n-   [ ] 增加 test\n-   [ ] 插件化\n-   [ ] aws lambda 接口\n\n### Bot 使用方法\n\n**当前仅支持用\".\" \"。\"和@机器人 三种开头方式。未来考虑增加多种前缀，但是为了方便统一前缀，这里可能不会做修改，需要大家自行修改。**\n`bot.processMsg=()=\u003e{}`\n\n添加 Command\n\n```ts\nbot.addCommands(echoMenu, echoKmd);\n```\n\n添加 Alias\n\n```ts\nbot.addAlias(echoMenu, '复读', '重复');\n```\n\n启动 Bot\n\n```ts\nbot.connect();\n```\n\n### SDK 使用方法\n\n```ts\nbot.message.on('text', (msg) =\u003e {});\nbot.event.on('system', (event) =\u003e {});\n```\n\n### Menu/App 使用方法\n\n请查看 src/commands 下的示例。\n\n```ts\nimport { MenuCommand } from 'commands/shared/menu';\nimport { BaseData } from 'commands/shared/types';\nimport { echoKmd } from './echo.kmd.app';\n\nclass EchoMenu extends MenuCommand {\n    code = 'echo';\n    trigger = 'echo';\n    help = '目前只有`.echo kmd`一个指令。';\n    intro = '复读菜单';\n}\n\nexport const echoMenu = new EchoMenu(echoKmd);\nechoMenu.addAlias(echoKmd, 'kmarkdown', '富文本');\n```\n\n```ts\nimport { AppCommand } from 'commands/shared/app';\nimport { AppFunc } from 'commands/shared/app.types';\nimport { BaseData } from 'commands/shared/types';\n\nclass EchoAll extends AppCommand {\n    code = 'all';\n    trigger = 'all';\n    help = '`.echo all 时间`';\n    intro = '在指定时间内复读全部文字';\n    func: AppFunc\u003cBaseSession\u003e = async (session) =\u003e {\n        session.setTextTrigger('', 6e4, (msg) =\u003e session.sendOnly(msg.content));\n        return session.reply('将会复读下一次任意内容，1min有效', session);\n    };\n}\n\nexport const echoAll = new EchoAll();\n```\n\n### 卡片消息相关\n\n可以使用官方提供的[卡片消息编辑器](https://www.kaiheila.cn/tools/message-builder.html#/card)\n\n完成编辑后，复制右侧自动生成的代码，然后把每张卡片使用`const cardObject = new Card({...这里是卡片的内容})`进行生成即可，发送的时候使用`session.sendCard(cardObject)`或`session.sendCardTemp(cardObject)`进行发送。\n\n你也可以直接复制自动生成的代码，使用`session.sendCard([cardObjects])`进行发送，具体可参考 src/commands 文件夹下的示例。\n\n## 更新历史\n\n### 0.2.10\n\n-   更新了文档\n-   不再强制需要对 Command 使用泛型，减少开发成本\n-   发送卡片消息时可以手动指定@、引用等选项了\n-   优化了代码结构，补充了部分 API 接口\n\n### 0.2.3\n\n-   可以直接在 `update message` 中使用 `card` 了\n-   将 `\\_botInstance` 重命名为 `client`，增加了 `deprecate` 标志\n-   `Card.toString()` 增加了选项，可以输出带有方括号或无方括号的 string。\n\n### 0.2.1\n\n-   更新了少量 API，`0.2.2` 版本将会覆盖 99% API\n-   增加了 `class Card`，废弃了之前使用 `parser` 的模式，提供更好的卡片消息操作性能。\n-   增加了 `GuildSession.awaitMessage`，允许开发者等待用户在当前频道的下一条消息。\n-   增加了 `collecter`，允许开发者在一定时间内收集频道内的消息，并且自定义停止的 trigger。\n-   解决了由于 pr#5 带来的 `mention`、`reply` 错误\n\n### 0.1.3\n\n-   替换 `BaseData` 为 `BaseSession`，简化了消息回复流程，增加对一次性文字 trigger 的支持。\n\n---\n\n特别感谢：[树根](https://github.com/shugen002)\n本项目基于 [BotRoot](https://github.com/shugen002/BotRoot) 开发\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffi6%2Fkbotify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffi6%2Fkbotify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffi6%2Fkbotify/lists"}