{"id":20390286,"url":"https://github.com/nonebot/adapter-kritor","last_synced_at":"2025-04-12T11:21:16.581Z","repository":{"id":230079671,"uuid":"778127309","full_name":"nonebot/adapter-kritor","owner":"nonebot","description":"NoneBot2 Kritor 协议适配器 / Kritor Protocol adapter for nonebot2","archived":false,"fork":false,"pushed_at":"2024-10-05T06:57:25.000Z","size":361,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T05:23:21.159Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/nonebot.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,"dei":null},"funding":{"open_collective":"nonebot","custom":["https://afdian.net/@nonebot"]}},"created_at":"2024-03-27T06:03:41.000Z","updated_at":"2025-03-09T09:34:42.000Z","dependencies_parsed_at":"2024-04-17T12:27:37.273Z","dependency_job_id":"80bf7840-d2d2-4538-a612-cbed096ab09b","html_url":"https://github.com/nonebot/adapter-kritor","commit_stats":{"total_commits":21,"total_committers":2,"mean_commits":10.5,"dds":0.04761904761904767,"last_synced_commit":"60046a10dc72e1a0ed83fb7a620083de4e96619e"},"previous_names":["nonebot/adapter-kritor"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nonebot%2Fadapter-kritor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nonebot%2Fadapter-kritor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nonebot%2Fadapter-kritor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nonebot%2Fadapter-kritor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nonebot","download_url":"https://codeload.github.com/nonebot/adapter-kritor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248558129,"owners_count":21124223,"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":[],"created_at":"2024-11-15T03:24:02.383Z","updated_at":"2025-04-12T11:21:16.560Z","avatar_url":"https://github.com/nonebot.png","language":"Python","funding_links":["https://opencollective.com/nonebot","https://afdian.net/@nonebot"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# NoneBot-Adapter-Kritor\n\n_✨ NoneBot2 Kritor Protocol适配器 / Kritor Protocol Adapter for NoneBot2 ✨_\n\n\u003c/div\u003e\n\n\u003e [!NOTE]\n\u003e Kritor 项目目前处于开发阶段, 所定义的 proto api 可能会有较大变动\n\u003e \n\u003e 若出现异常情况请确定本仓库使用的 kritor api 与所对接的协议端使用的 kritor api 是否相同\n\n## 协议介绍\n\n[Kritor Protocol](https://github.com/KarinJS/kritor)\n\n### 协议端\n\n目前提供了 `kritor` 协议实现的有：\n- [Lagrange.Kritor](https://github.com/LagrangeDev/Lagrange.Kritor)\n- Shamrock\n\n\n## 配置\n\n修改 NoneBot 配置文件 `.env` 或者 `.env.*`。\n\n### Driver\n\n因本适配器基于 `gRPC`，Nonebot 没有现有的相关驱动器，所以驱动请直接写 `none`:\n\n\n```dotenv\nDRIVER=~none\n```\n\n### KRITOR_CLIENTS\n\n配置机器人帐号，如：\n\n```dotenv\nKRITOR_CLIENTS='\n[\n  {\n    \"host\": \"xxx\",\n    \"port\": xxx,\n    \"account\": \"xxx\",\n    \"ticket\": \"xxx\"\n  }\n]\n'\nKRITOR_SKIP_AUTH=false\n```\n\n其中，\n\n- `host`: 服务端的地址，默认为 localhost\n- `port`: 服务端的端口\n- `account`: bot 登录的账号\n- `ticket`: bot 登录用的凭证/密码\n- `KRITOR_SKIP_AUTH`: 若协议端未启用鉴权功能，则启用此配置项。此时 `ticket` 留空即可。\n\n### 以对接 Lagrange.Kritor 为例\n\n首先按照 [Lagrange.Kritor](https://github.com/LagrangeDev/Lagrange.Kritor) 的 README 进行配置。进行下一步前你应当已经创建好了 `appsettings.json`:\n\n```json5\n// appsettings.json\n{\n    \"Logging\": {\n        \"LogLevel\": {\n            // Log level, please modify to `Trace` when providing feedback on issues\n            \"Default\": \"Information\"\n        }\n    },\n    \"Core\": {\n        \"Protocol\": {\n            // Protocol platform, please modify according to the Signer version\n            // Type: String (\"Windows\", \"MacOs\", \"Linux\")\n            // Default: \"Linux\"\n            \"Platform\": \"Linux\",\n            \"Signer\": {\n                // Signer server url\n                // Type: String (HTTP URL, HTTPS URL)\n                \"Url\": \"\",\n                // Signer server proxy\n                // Type: String (HTTP URL)\n                \"Proxy\": \"\"\n            }\n        },\n        \"Server\": {\n            // Whether to automatically reconnect to the TX server\n            // Type: bool\n            // Default: false\n            \"AutoReconnect\": true,\n            // Whether to get optimum server\n            // Type: bool\n            // Default: false\n            \"GetOptimumServer\": true\n        }\n    },\n    \"Kritor\": {\n        \"Network\": {\n            // Address of the Kritor service binding\n            // Type: String (ip)\n            \"Address\": \"0.0.0.0\",\n            // Port of the Kritor service binding\n            // Type: Number ([1-65535])\n            \"Port\": 9000\n        },\n        \"Authentication\": {\n            // Whether to enable authentication\n            // Type: bool\n            \"Enabled\": false,\n            // Ticket with maximum privileges\n            // Type: String\n            \"SuperTicket\": \"\",\n            // Ticket list\n            // Type: String[]\n            \"Tickets\": []\n        },\n        \"Message\": {\n            // Whether to ignore your own messages\n            // Type: bool\n            \"IgnoreSelf\": false\n        }\n    }\n}\n```\n\n对于配置项:\n- `host` 与 `Kritor.Network.Address` 一致\n- `port` 与 `Kritor.Network.Port` 一致\n- 若 `Kritor.Authentication.Enabled` 为 true, 则 `ticket` 应存在于 `.SuperTicket` 或 `.Tickets` 中\n- `account` 为你登录的账号\n\n\n## 克隆\n\n因为该仓库包含一个 submodule, 请使用以下命令克隆本仓库：\n\n```bash\ngit clone --recursive https://github.com/nonebot/adapter-kritor.git\n```\n\n## 示例\n\n```python\nfrom nonebot import on_command\nfrom nonebot.adapters.kritor import Bot\nfrom nonebot.adapters.kritor.message import MessageSegment\nfrom nonebot.adapters.kritor.permission import PRIVATE\n\n\nmatcher = on_command(\"test\", permission=PRIVATE)\n\n@matcher.handle()\nasync def handle_receive(bot: Bot):\n    await bot.send(event, MessageSegment.text(\"Hello, world!\"))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnonebot%2Fadapter-kritor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnonebot%2Fadapter-kritor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnonebot%2Fadapter-kritor/lists"}