{"id":20612636,"url":"https://github.com/quqionfree/qqbot","last_synced_at":"2025-04-15T07:08:26.849Z","repository":{"id":82458672,"uuid":"603288473","full_name":"quqiOnfree/qqbot","owner":"quqiOnfree","description":"这是一个QQ机器人，拥有强大的自定义功能（插件系统）(A bot for QQ)","archived":false,"fork":false,"pushed_at":"2024-04-21T06:34:29.000Z","size":1139,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-15T07:08:21.111Z","etag":null,"topics":["cpp","cpp-httplib","cpp23","go-cqhttp","qqbot"],"latest_commit_sha":null,"homepage":"","language":"C++","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/quqiOnfree.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}},"created_at":"2023-02-18T03:35:42.000Z","updated_at":"2025-03-04T23:26:30.000Z","dependencies_parsed_at":"2024-01-28T08:25:21.648Z","dependency_job_id":"29ef1174-c4e3-4110-bc7c-1716f221b996","html_url":"https://github.com/quqiOnfree/qqbot","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quqiOnfree%2Fqqbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quqiOnfree%2Fqqbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quqiOnfree%2Fqqbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quqiOnfree%2Fqqbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quqiOnfree","download_url":"https://codeload.github.com/quqiOnfree/qqbot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249023723,"owners_count":21199960,"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":["cpp","cpp-httplib","cpp23","go-cqhttp","qqbot"],"created_at":"2024-11-16T11:07:32.634Z","updated_at":"2025-04-15T07:08:26.820Z","avatar_url":"https://github.com/quqiOnfree.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QQ机器人\n## 介绍\n- 这个QQ机器人拥有插件系统，可以轻松扩展\n- 语言：C++23\n\n## 依赖\n### 前置依赖\n- [cpp-httplib](https://github.com/yhirose/cpp-httplib)\n- [go-cqhttp](https://github.com/Mrs4s/go-cqhttp)\n- [asio](https://github.com/chriskohlhoff/asio)\n- [openssl](https://github.com/openssl/openssl)\n### 构建\n1. 安装 cmake vcpkg c++编译器\n2. 执行以下命令  \n   ```cmd\n   vcpkg install openssl\n   vcpkg install cpp-httplib\n   vcpkg install asio\n   ```\n3. 构建此程序\n   ```cmd\n   cd 此程序的目录\n   cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=你的vcpkg的目录/scripts/buildsystems/vcpkg.cmake\n   cd build\n   cmake --build . --config Release -j8\n   ```\n4. 1. 配置[go-cqhttp](https://github.com/Mrs4s/go-cqhttp)\n   2. 运行go-cqhttp再运行此程序即可使用\n\n## 功能\n### QQ机器人插件系统\n#### 创建插件\n- 此机器人只有一个框架，用于插件扩展，所有指令（除了基本的help等基础指令）都是通过插件加入  \n- 插件类  \n```cpp\n#pragma once\n\n#include \u003cstring\u003e\n\n#include \"command.h\"\n#include \"permission.h\"\n\nnamespace qqbot\n{\n    struct PluginInfo\n    {\n        //插件名称\n        std::string name;\n\n        //插件作者名\n        std::string author;\n\n        //插件版本\n        std::string version;\n    };\n\n    class CppPlugin\n    {\n    public:\n        //禁止复制，只能移动\n        CppPlugin() = default;\n        CppPlugin(const CppPlugin\u0026) = delete;\n        ~CppPlugin() = default;\n\n        CppPlugin\u0026 operator =(const CppPlugin\u0026) = delete;\n\n        //插件加载\n        virtual void onLoad()\n        {\n        }\n\n        //插件启动\n        virtual void onEnable()\n        {\n        }\n\n        //插件关闭\n        virtual void onDisable()\n        {\n        }\n\n    public:\n        //插件信息\n        PluginInfo pluginInfo;\n\n    private:\n\n    };\n}\n\n```\n\n- 插件例子[groupOperator.h](./plugin/groupOperator.h)  \n```cpp\n#include \u003chttplib.h\u003e\n#include \u003cJson.h\u003e\n#include \u003cvector\u003e\n#include \u003cstring\u003e\n\n//最基本的三个库\n#include \"cppPlugin.h\"\n#include \"pluginLibrary.h\"\n#include \"network.h\"\n\nnamespace GroupOperator\n{\n    class GroupOperatorPlugin : public qqbot::CppPlugin //继承插件类\n    {\n    public:\n        GroupOperatorPlugin()\n        {\n            qqbot::CppPlugin::pluginInfo.author = \"quqiOnfree\";            //作者名\n            qqbot::CppPlugin::pluginInfo.name = \"GroupOperator群组管理插件\";//插件名称\n            qqbot::CppPlugin::pluginInfo.version = \"0.0.1\";                //插件版本\n        }\n\n        ~GroupOperatorPlugin() = default;\n\n        virtual void onLoad()\n        {\n            //这里是插件加载之前执行\n        }\n\n        virtual void onEnable()\n        {\n            //这里是插件加载完成时启动执行\n\n            //添加指令\n            qqbot::ServerInfo::getCommander().addCommand(\"kick\",//命令名称\n                [this](long long groupID,\n                    long long senderID,\n                    const std::string\u0026 commandName,\n                    std::vector\u003cstd::string\u003e Args)              //lambda表达式或符合格式的函数\n                {\n                    //...\n                },\n                \"kick userid true/false\",       //命令格式\n                \"踢出群成员\"                    //命令作用解释\n                );\n\n            //设置权限\n            qqbot::ServerInfo::getPermission().setGroupDefaultPermission(\"kick\", false);\n            //true是普通用户可以访问，false是管理员可以访问\n            //这个可以在配置文件里面进行编辑\n        }\n    };\n}\n\n\n```\n#### 加载插件  \n需要在[register.cpp](./register/register.cpp)加入一些代码\n```cpp\n//导入插件\n#include \"pluginName.h\" //插件名\n\nnamespace qqbot\n{\n    //修改此函数\n    void Register::init()\n    {\n        //添加插件（以GroupOperator为例）\n        //this-\u003eaddPlugin(std::make_shared\u003c插件命名空间::插件类\u003e());\n        this-\u003eaddPlugin(std::make_shared\u003cGroupOperator::GroupOperatorPlugin\u003e());\n    }\n    \n    //省略下面代码\n    //...\n}\n\n```\n## 开发此qqbot\n### qqbot的各种系统及API\n- 权限系统 [Permission System](./doc/permission.md)\n- 命令系统 [Command System](./doc/command.md)\n- 插件系统 [Plugin System](./doc/plugin.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquqionfree%2Fqqbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquqionfree%2Fqqbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquqionfree%2Fqqbot/lists"}