{"id":13742561,"url":"https://github.com/shugen002/BotRoot","last_synced_at":"2025-05-09T00:31:26.812Z","repository":{"id":41272735,"uuid":"322176087","full_name":"shugen002/BotRoot","owner":"shugen002","description":"开黑啦机器人JavaScript SDK","archived":true,"fork":false,"pushed_at":"2023-03-19T14:23:09.000Z","size":424,"stargazers_count":17,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T07:13:26.071Z","etag":null,"topics":["bot","kaiheila"],"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/shugen002.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-12-17T04:04:23.000Z","updated_at":"2024-09-16T13:47:06.000Z","dependencies_parsed_at":"2024-01-13T01:37:46.761Z","dependency_job_id":"ef84769f-ea76-4edb-a2d5-18b9767c40df","html_url":"https://github.com/shugen002/BotRoot","commit_stats":{"total_commits":58,"total_committers":2,"mean_commits":29.0,"dds":"0.31034482758620685","last_synced_commit":"feb8badf8bc1b425300510e5c75e99b1aedf6ae7"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shugen002%2FBotRoot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shugen002%2FBotRoot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shugen002%2FBotRoot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shugen002%2FBotRoot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shugen002","download_url":"https://codeload.github.com/shugen002/BotRoot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253170935,"owners_count":21865273,"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","kaiheila"],"created_at":"2024-08-03T05:00:33.626Z","updated_at":"2025-05-09T00:31:26.451Z","avatar_url":"https://github.com/shugen002.png","language":"TypeScript","readme":"# BotRoot\n\n开黑啦机器人 JavaScript SDK\n\n## 安装 install\n\n```\nnpm i kaiheila-bot-root\n```\n\n## 用法 usage\n\n### Webhook 独立模式\n\n在开黑啦机器人概况中选择连接模式为 webhook 并设置为\n\n```\nhttp://你的公网IP或域名:8600/?compress=0\n```\n\n代码：\n\n```js\nvar Bot = require('kaiheila-bot-root').KaiheilaBot\nvar bot = new Bot({\n  mode: 'webhook',\n  port: 8600,\n  key: 'YOUR ENCRYPT KEY', // 和设置的一致，如果这个值为空视为不加密\n  token: 'YOUR TOKEN',\n  verifyToken: 'YOUR VERIFY TOKEN',\n})\n\n/**\n * 输出保存原始数据\n */\nbot.messageSource.on('message', (e) =\u003e {\n  console.log(e)\n  if (typeof e.msg_id === 'string') {\n    writeFile(\n      `cache/${e.msg_id}.json`,\n      JSON.stringify(e, undefined, 2),\n      (e) =\u003e {\n        if (e) {\n          console.error(e)\n        }\n      }\n    )\n  }\n})\n/**\n * 监听文本信息\n */\nbot.on('textMessage', (e) =\u003e {\n  console.log(e)\n})\n\nbot.listen()\n```\n\n### Webhook 合并模式\n\n做了，懒得写了\n\n### websocket 模式\n\n```js\nvar Bot = require('kaiheila-bot-root').KaiheilaBot\nvar bot = new Bot({\n  mode: 'websocket',\n  token: 'YOUR TOKEN',\n})\n\n/**\n * 输出保存原始数据\n */\nbot.messageSource.on('message', (e) =\u003e {\n  console.log(e)\n  if (typeof e.msg_id === 'string') {\n    writeFile(\n      `cache/${e.msg_id}.json`,\n      JSON.stringify(e, undefined, 2),\n      (e) =\u003e {\n        if (e) {\n          console.error(e)\n        }\n      }\n    )\n  }\n})\n/**\n * 监听文本信息\n */\nbot.on('textMessage', (e) =\u003e {\n  console.log(e)\n})\n\nbot.listen()\n```\n","funding_links":[],"categories":["SDK"],"sub_categories":["官方服务器"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshugen002%2FBotRoot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshugen002%2FBotRoot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshugen002%2FBotRoot/lists"}