{"id":34133662,"url":"https://github.com/afraidjpg/rbq-go","last_synced_at":"2026-03-09T23:02:39.964Z","repository":{"id":43868316,"uuid":"457686941","full_name":"afraidjpg/rbq-go","owner":"afraidjpg","description":"目标是成为一个对插件开发友好的一个qq bot插件框架","archived":false,"fork":false,"pushed_at":"2023-10-18T07:00:47.000Z","size":282,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-17T12:19:09.374Z","etag":null,"topics":["bot","go","go-cqhttp","golang","qq","qq-bot","qqbot"],"latest_commit_sha":null,"homepage":"","language":"Go","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/afraidjpg.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"support/plugin.go","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-10T08:10:17.000Z","updated_at":"2024-12-11T09:41:27.000Z","dependencies_parsed_at":"2023-07-12T23:08:04.169Z","dependency_job_id":"6aced4f7-bf3d-4478-87e8-6156b23546ee","html_url":"https://github.com/afraidjpg/rbq-go","commit_stats":{"total_commits":28,"total_committers":3,"mean_commits":9.333333333333334,"dds":0.3571428571428571,"last_synced_commit":"c9987827844fd7a14b88e6ab27de1c644742c95e"},"previous_names":["alive1944/qq-robot-go"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/afraidjpg/rbq-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afraidjpg%2Frbq-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afraidjpg%2Frbq-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afraidjpg%2Frbq-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afraidjpg%2Frbq-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/afraidjpg","download_url":"https://codeload.github.com/afraidjpg/rbq-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afraidjpg%2Frbq-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30315974,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","go","go-cqhttp","golang","qq","qq-bot","qqbot"],"created_at":"2025-12-15T01:11:43.931Z","updated_at":"2026-03-09T23:02:39.954Z","avatar_url":"https://github.com/afraidjpg.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv style=\"text-align: center\"\u003e\n\n\u003ch1\u003erbq-go\u003c/h1\u003e\n\u003ch3\u003e一个以go-cqhttp为后端的插件开发框架\u003c/h3\u003e\n\n![](https://img.shields.io/badge/go-v1.18%2B-blue)\n[![](https://img.shields.io/badge/go--cqhttp-v1.0.0+-orange)](https://github.com/Mrs4s/go-cqhttp)\n\n\u003c/div\u003e\n\n## 写在前面\n\n这是一个个人学习性质的项目，不能提供任何可靠性保证，包括但不限于：**代码安全与质量，相关文档，issue回复的及时性等**。\n\n基于上述理由，本项目的更新速度可能会十分缓慢（就是懒）。如果star高了，用的人多了，项目变得活跃了，那我应该会变得很积极（手动狗头）\n\n一个人的力量是有限的，所以如果你愿意使用，并在使用过程中有任何问题、新的feature/代码修改建议，欢迎提出issue，我会尽可能的回复并改进。\n\n\u003cspan style=\"font-size:18px\"\u003ePS: rbq = **r**o**b**ot **q**q\u003c/span\u003e\n\n\u003ch2\u003e简介\u003c/h2\u003e\n\nrbq-go是一个以go-cqhttp为后端的插件开发框架，它的目标是提供一个简单、易用的插件开发环境，通过封装go-cqhttp的api，使插件开发者可以更简单的与qq交互。\n\n项目灵感来自于许久以前写着玩儿的时候，发现要写一堆代码去调用后端，感觉很麻烦，于是有了写这个项目的念头，我但愿这个项目能够帮助到你。\n\n为了保持项目简单易懂，项目会 **尽量避免使用过于复杂的设计**\n，降低学习成本。同时保留高级功能的空间，使之可以胜任复杂场景。期望是不再需要理解以及再封装onebot的文档，即可简单的开发插件\n\n## 安装\n\n```\ngo get -u github.com/afraidjpg/rbq-go\n```\n\n## 使用\n\n示例代码请 [点击这里](./example)\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/afraidjpg/rbq-go\"\n)\n\n// YourPlugin 这是你的插件本体\nfunc YourPlugin(ctx *rbq.Context) {\n\tmsg := ctx.GetMessage()\n\tif msg == \"hello world\" {\n\t\tctx.Reply(\"welcome\")\n\t\treturn\n\t}\n\n\tctx.Reply(\"test\") // 发送 \"test\"\n\n\tctx.AddText(\"boo\") // 添加消息但不立刻发送\n\tctx.AddText(\"bar\")\n\tctx.Reply() // 发送 \"boobar\"\n\n\tctx.AddText(\"hello\") // 添加消息但不立刻发送\n\tctx.AddText(\" \")\n\tctx.Reply(\"world\") // 发送 \"hello world\"\n}\n\n// main 方法\nfunc main() {\n\tbot := rbq.NewApp()          // 新建app\n\tpld := bot.GetPluginLoader() // 获取插件装载器\n\t// 添加单个插件\n\tpld.BindPlugin(YourPlugin, nil)\n\n\t// 创建一个插件组，并向插件组中加入插件\n\tgp := pld.Group(\"gp\", nil)\n\tgp.BindPlugin(YourPlugin, nil)\n\n\t// 添加插件中发生的错误\n\terrs := gp.GetErrors()\n\tif len(errs) \u003e 0 {\n\t\tfor _, err := range errs {\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t}\n\t// 不给参数，自动设置为 127.0.0.1:8080（go-cqhttp的默认正向websocket端口）\n\tbot.Run(\"\")\n}\n```\n\n## 运行\n\n- 下载 [go-cqhttp](https://github.com/Mrs4s/go-cqhttp/releases)\n- 启动 `go-cqhttp` 并使用选择正向websocket连接\n- 运行你的程序\n\n\u003ch2\u003e插件选项\u003c/h2\u003e\n\n`BindPlugin`的第二个参数是一个`*PluginOption`类型的变量，可以为插件设置一些选项，例如：\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/afraidjpg/rbq-go\"\n)\n\nvar SimpleOption = \u0026rbq.PluginOption{\n\tName: \"example_reply\", // 插件名称\n\tFilterFunc: []rbq.PluginFilterFunc{\n\t\tfunc(ctx *rbq.Context) bool {\n\t\t\treturn ctx.IsGroup() // 只回复群消息\n\t\t},\n\t},\n\tRecoverFunc: func(ctx *rbq.Context, err any) {\n\t\tfmt.Println(\"插件运行错误:\", err)\n\t}, // 当插件运行错误的时候执行的逻辑\n}\n\nfunc YourPlugin(ctx *rbq.Context) {\n\tctx.Reply(\"test\")\n}\n\n// 然后在绑定插件的时候使用\nfunc main() {\n\tbot := rbq.NewApp()\n\tpld := bot.GetPluginLoader()\n\tpld.BindPlugin(YourPlugin, SimpleOption) // 该插件将应用上述设置\n\n\tgp := pld.Group(\"gp\", \u0026rbq.PluginGroupOption{SimpleOption})\n\tgp.BindPlugin(YourPlugin, nil) // gp组内的插件选项如果未设置，则会直接应用gp组的选项\n\t// ...\n}\n\n```\n\n## CQ码\n\n### 使用示例\n\n```go\npackage yourplugin\n\nimport (\n\t\"fmt\"\n\t\"github.com/afraidjpg/rbq-go\"\n)\n\nfunc YourPlugin(ctx *rbq.Context) {\n\t// 获取该条消息中的所有CQ码，返回类型为 []CQCodeInterface，需要手动转换类型\n\tcq := ctx.GetAllCQCode()\n\tfmt.Println(cq)\n\n\t// 获取具体的某种CQ码的方式为 ctx.GetCQX(), 其中X为CQ码的类型\n\t// 需要注意的是，一条消息中允许存在多个相同类型的CQ码时，会返回[]*CQX\n\t// 如果不会返回多个，则返回*CQX \n\t// 例如 ctx.GetCQAt() 获取at码\n\tats := ctx.GetCQAt() // 返回 []*CQAt，获取该条消息中的所有at\n\tfor _, at := range ats {\n\t\tfmt.Println(at.GetQQ()) // 获取at的qq号\n\t}\n\n\t// 发送CQ码的方式为 ctx.AddCQX(), X代表CQ码类型，且首字母大写\n\t// 如 At、Image、Face...\n\tctx.AddCQAt(1234567)\n\tctx.AddCQFace(22)\n\t// ...\n\n\tctx.Reply() // 发送消息\n}\n\n```\n\n### 支持的CQ码\nCQ码的支持与 go-cqhttp 同步，可以[点击这里](https://github.com/Mrs4s/go-cqhttp)查看README中对CQ码的描述\n\n|    CQ码    | 进度  | 收发限制 | 备注                                                                    |\n|:---------:|:---:|:----:|-----------------------------------------------------------------------|\n|   face    | 完成  | 收\u0026发  |                                                                       |                                                                       |\n|  record   | 完成  | 收\u0026发  | ⚠️可能存在问题，具体查看该[issue](https://github.com/Mrs4s/go-cqhttp/issues/1749) |\n|   video   | 完成  | 收\u0026发  | 如果没有后缀，通常为mp4                                                         |\n|    at     | 完成  | 收\u0026发  |                                                                       |\n|   share   | 完成  | 收\u0026发  | ⚠️对群时发送/接受时可能会失败                                                      |\n|   music   | 完成  | 收\u0026发  |                                                                       |\n|   reply   | 完成  | 收\u0026发  |                                                                       |\n|  forward  | 完成  |  收   |                                                                       |\n|   node    | 完成  |  发   |                                                                       |\n|    xml    | 未实现 |      |                                                                       |\n|   json    | 未实现 |      |                                                                       |\n|   image   | 完成  | 收\u0026发  |                                                                       |\n|  redbag   | 完成  |  收   |                                                                       |\n|   poke    | 完成  |  发   |                                                                       |\n| cardimage | 完成  |  发   |                                                                       |\n|    tts    | 完成  |  发   |                                                                       |\n\n## bot API\n\n实现了对 go-cqhttp 的 api 调用封装，可以通过 `ctx.Api` 或者 `rbq.GetBotApi()` 获取机器人api对象，\n然后调用对应的方法即可\n\n### 使用示例\n\n```go\npackage yourplugin\n\nimport (\n\t\"github.com/afraidjpg/rbq-go\"\n\t\"log\"\n\t\"time\"\n)\n\nfunc BotApi(ctx *rbq.Context) {\n\tmsgId, _, err := ctx.Reply(\"阿巴阿巴阿巴\")\n\tif err != nil {\n\t\treturn\n\t}\n\n\ttime.Sleep(time.Second * 5) // 5秒后撤回消息\n\terr = ctx.Api.DeleteMsg(msgId)\n\t// 也可以这样调用\n\t// err = rbq.GetBotApi().DeleteMsg(msgId)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\tlog.Println(\"撤回消息成功：\", msgId)\n}\n\n```\n\n|      分类      |          名称          |             方法名             |         go-cqhttp 接口名          |    进度     |\n|:------------:|:--------------------:|:---------------------------:|:------------------------------:|:---------:|\n|    bot账号     |       获取登录号信息        |        GetLoginInfo         |         get_login_info         |    完成     |\n|    bot账号     |       设置登录号资料        |        SetQQProfile         |         set_qq_profile         |    完成     |\n|    bot账号     |       获取企点账号信息       |    GetQidianAccountInfo     |    qidian_get_account_info     |    完成     |\n|    bot账号     |        获取在线机型        |        GetDeviceList        |        _get_model_show         |    完成     |\n|    bot账号     |        设置在线机型        |       SetOnlineDevice       |        _set_model_show         |    完成     |\n|    bot账号     |        获取在线设备        |      GetOnlineClients       |       get_online_clients       |    完成     |\n|     好友信息     |       获取陌生人信息        |       GetStrangerInfo       |       get_stranger_info        |    完成     |\n|     好友信息     |        获取好友列表        |        GetFriendList        |        get_friend_list         |    完成     |\n|     好友信息     |       获取单向好友列表       | GetUnidirectionalFriendList | get_unidirectional_friend_list |    完成     |\n|     好友操作     |         删除好友         |        DeleteFriend         |         delete_friend          |    完成     |\n|     好友操作     |         删除单向         | DeleteUnidirectionalFriend  |  delete_unidirectional_friend  |    完成     |\n|      消息      |        发送私聊消息        |       SendPrivateMsg        |        send_private_msg        |    完成     |\n|      消息      |        发送群消息         |        SendGroupMsg         |         send_group_msg         |    完成     |\n|      消息      |         发送消息         |           SendMsg           |            send_msg            |    完成     |\n|      消息      |         获取消息         |           GetMsg            |            get_msg             |    完成     |\n|      消息      |         撤回消息         |          DeleteMsg          |           delete_msg           |    完成     |\n|      消息      |        标记消息已读        |        MarkMsgAsRead        |        mark_msg_as_read        |    完成     |\n|      消息      |       获取合并转发内容       |        GetforwardMsg        |        get_forward_msg         |    完成     |\n|      消息      |    发送合并转发 ( 群聊 )     |     SendGroupForwardMsg     |     send_group_forward_msg     |    完成     |\n|      消息      |    发送合并转发 ( 好友 )     |    SendPrivateForwardMsg    |    send_private_forward_msg    |    完成     |\n|      消息      |      获取群消息历史记录       |     GetGroupMsgHistory      |     get_group_msg_history      |    完成     |\n|      图片      |        获取图片信息        |          GetImage           |           get_image            |    完成     |\n|      图片      |      检查是否可以发送图片      |        CanSendImage         |         can_send_image         |    完成     |\n|      图片      |        图片 OCR        |          OcrImage           |           ocr_image            |    完成     |\n|      语音      |         获取语音         |          GetRecord          |           get_record           | cqhttp未实现 |\n|      语音      |      检查是否可以发送语音      |        CanSendRecord        |        can_send_record         |    完成     |\n|      处理      |       处理加好友请求        |     SetFriendAddRequest     |     set_friend_add_request     |    完成     |\n|      处理      |      处理加群请求／邀请       |     SetGroupAddRequest      |     set_group_add_request      |    完成     |\n|     群信息      |        获取群信息         |        GetGroupInfo         |         get_group_info         |    完成     |\n|     群信息      |        获取群列表         |        GetGroupList         |         get_group_list         |    完成     | \n|     群信息      |       获取群成员信息        |     GetGroupMemberInfo      |     get_group_member_info      |    完成     |\n|     群信息      |       获取群成员列表        |     GetGroupMemberList      |     get_group_member_list      |    完成     |\n|     群信息      |       获取群荣誉信息        |      GetGroupHonorInfo      |      get_group_honor_info      |    完成     |\n|     群信息      |       获取群系统消息        |      GetGroupSystemMsg      |      get_group_system_msg      |    完成     |\n|     群信息      |       获取精华消息列表       |      GetEssenceMsgList      |      get_essence_msg_list      |    完成     |\n|     群信息      |    获取群 @全体成员 剩余次数    |     GetGroupAtAllRemain     |    get_group_at_all_remain     |    完成     |\n|     群设置      |         设置群名         |        SetGroupName         |         set_group_name         |    完成     |\n|     群设置      |        设置群头像         |      SetGroupPortrait       |       set_group_portrait       |    完成     |\n|     群设置      |        设置群管理员        |        SetGroupAdmin        |        set_group_admin         |    完成     |\n|     群设置      |    设置群名片 ( 群备注 )     |        SetGroupCard         |         set_group_card         |    完成     |\n|     群设置      |       设置群专属头衔        |    SetGroupSpecialTitle     |    set_group_special_title     |    完成     |\n|     群操作      |        群单人禁言         |         SetGroupBan         |         set_group_ban          |    完成     |\n|     群操作      |        群全员禁言         |      SetGroupWholeBan       |      set_group_whole_ban       |    完成     |\n|     群操作      |       群匿名用户禁言        |    SetGroupAnonymousBan     |    set_group_anonymous_ban     | cqhttp未实现 |\n|     群操作      |        设置精华消息        |        SetEssenceMsg        |        set_essence_msg         |    完成     |\n|     群操作      |        删除精华消息        |      DeleteEssenceMsg       |       delete_essence_msg       |    完成     |\n|     群操作      |         群打卡          |        SendGroupSign        |        send_group_sign         |    完成     |\n|     群操作      |        群设置匿名         |      SetGroupAnonymous      |      set_group_anonymous       |    完成     |\n|     群操作      |        发送群公告         |       SendGroupNotice       |       _send_group_notice       |    完成     |\n|     群操作      |        获取群公告         |       GetGroupNotice        |       _get_group_notice        |    完成     |\n|     群操作      |         群组踢人         |        SetGroupKick         |         set_group_kick         |    完成     |\n|     群操作      |         退出群组         |        SetGroupLeave        |        set_group_leave         |    完成     |\n|      文件      |        上传群文件         |       UploadGroupFile       |       upload_group_file        |    完成     |\n|      文件      |        删除群文件         |       DeleteGroupFile       |       delete_group_file        |    完成     |\n|      文件      |       创建群文件文件夹       |    CreateGroupFileFolder    |    create_group_file_folder    |    完成     |\n|      文件      |       删除群文件文件夹       |    DeleteGroupFileFolder    |      delete_group_folder       |    完成     |\n|      文件      |      获取群文件系统信息       |   GetGroupFileSystemInfo    |   get_group_file_system_info   |    完成     |\n|      文件      |      获取群根目录文件列表      |      GetGroupRootFiles      |      get_group_root_files      |    完成     |\n|      文件      |      获取群子目录文件列表      |    GetGroupFilesByFolder    |   get_group_files_by_folder    |    完成     |\n|      文件      |      获取群文件资源链接       |       GetGroupFileUrl       |       get_group_file_url       |    完成     |\n|      文件      |        上传私聊文件        |      UploadPrivateFile      |      upload_private_file       |    完成     |\n| Go-CqHttp 相关 |      获取 Cookies      |         GetCookies          |          get_cookies           | cqhttp未实现 |\n| Go-CqHttp 相关 |    获取 CSRF Token     |        GetCsrfToken         |         get_csrf_token         | cqhttp未实现 |\n| Go-CqHttp 相关 |     获取 QQ 相关接口凭证     |       GetCredentials        |        get_credentials         | cqhttp未实现 |\n| Go-CqHttp 相关 |        获取版本信息        |       GetVersionInfo        |        get_version_info        |    完成     |\n| Go-CqHttp 相关 |         获取状态         |          GetStatus          |           get_status           |    完成     |\n| Go-CqHttp 相关 |         清理缓存         |         CleanCache          |          clean_cache           |    完成     |\n| Go-CqHttp 相关 |       重载事件过滤器        |      ReloadEventFilter      |      reload_event_filter       |    完成     |\n| Go-CqHttp 相关 |      下载文件到缓存目录       |        DownloadFile         |         download_file          |    完成     |\n| Go-CqHttp 相关 |       检查链接安全性        |       CheckUrlSafely        |        check_url_safely        |    完成     |\n| Go-CqHttp 相关 |  获取中文分词 ( 隐藏 API )   |        getWordSlices        |        .get_word_slices        |    完成     |\n| Go-CqHttp 相关 | 对事件执行快速操作 ( 隐藏 API ) |    handleQuickOperation     |    .handle_quick_operation     |    完成     |\n\n## 全局信息\n\n内置了一些全局变量，在程序启动后可以从中获取一些全局性的信息\n\n### 使用\n\n```go\npackage your_package\n\nimport (\n\t\"github.com/afraidjpg/rbq-go\"\n\t\"log\"\n)\n\nfunc GlobalInfo(ctx *rbq.Context) {\n\tlog.Println(ctx.GlobalInfo.GetBotQQ())\n\tlog.Println(rbq.GetGlobalInfo().GetBotQQ())\n}\n\n```\n\n### 可用信息\n\n| 方法名 | 说明 |\n| :----: | :----: |\n| GetBotQQ | 获取机器人QQ号 |\n| GetBotNickname | 获取机器人昵称 |\n| CanSendImg | 是否可以发送图片 |\n| CanSendRecord | 是否可以发送语音 |\n| GetOnlineClients | 获取在线客户端列表 |\n| GetFriendList | 获取好友列表 |\n| GetUnidirectionalFriendList | 获取单向好友列表 |\n| GetGroupList | 获取群列表 |\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafraidjpg%2Frbq-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fafraidjpg%2Frbq-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafraidjpg%2Frbq-go/lists"}