Tips~ 如有意向一起开发本项目,请联系我邮箱 ( ̄▽ ̄)"
API文档(包含示例) · 文档库 · demo
支持的事件
这些内容可以在Config.kt看到
事件名称 | 函数名称 |
---|---|
机器人上线 | BotOnlineEvent |
群聊消息 | GroupMessageEvent |
私聊消息 | PrivateMessageEvent |
好友申请 | NewFriendRequestEvent |
群聊邀请 | GroupInviteEvent |
新群成员申请 | MemberJoinRequestEvent |
新群成员加入 | MemberJoinEvent |
群成员离开 | MemberLeaveEvent |
机器人加入 | BotJoinEvent |
机器人离开 | BotLeaveEvent |
消息撤回 | RecallEvent |
群临时会话 | GroupTempMessageEvent |
定时事件执行 | SchedulingEvent |
戳一戳 | NugdeEvent |
- C++ 17
- 使用cmake
- 使用jni与kt交互
- c++ utf8编码
- 与mirai-core同步发布(无需mah)
- 支持3种使用方法(mcl, MiraiCP-loader 以及 MiraiCP-core)
- [从2.7.0开始]代码集中到一个hpp文件和其他固定依赖文件,每次更新只需要更新那个文件
- 不封装和隐藏底层实现代码,您可以自定义实现代码或通过实现代码提issue/pr
CI Name | status |
---|---|
C++ in windows(mingw&msvc) & linux(g++) | |
kotlin |
-
MiraiCP是一个Mirai 的C++语言的社区SDK,基于Mirai-console和Mirai-core插件模板开发
-
本项目仅供学习参考,禁止用于任何商业用途(根据Mirai的AGPLv3许可协议开源)。
-
本项目不含有任何旨在破坏用户计算机数据和获取用户隐私的恶意代码,不含有任何跟踪、监视用户计算机功能代码,不会收集任何用户个人信息,不会泄露用户隐私。
-
本项目不提供任何具体功能实现,仅仅只是对项目mirai-console和mirai-core(详见mirai仓库)的二次封装。
-
任何单位或个人认为本项目可能涉嫌侵权,应及时提出反馈,本项目将会第一时间对违规内容给予删除等相关处理。
mirai需要java环境 >=11
- 从v2.6.3-RC开始,使用utf8作为编码, vs需要加/utf8编译参数,见微软文档, 而在CmakeLists里就表现为
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
- MiraiCP版本规则: 从2.2.0开始 (2021/1/31),版本前两位为Mirai的版本,后一位为SDK更新迭代版本
deprecated
方法一般只保存3个版本- 编译出的插件不具备跨平台性, 如在 windows 下编译的库在 linux 上无法使用, 要在和目标同系统下编译或者用 cmake 交叉编译
- 请确保您熟悉现代C++的语法,以及C++动态链接库相关的知识!如果遇到无法解决的编译、链接问题,请先查阅资料,当您确定问题在于MiraiCP时,请提issue或者在qq群联系我们
- 选择启动方式
- MiraiCP-plugin 使用 Mirai-Console-Loader 进行启动, 适用于需要同时使用其他 Mirai 社区中插件的情况
- MiraiCP-loader 使用 MiraiCP loader 组件进行启动, 适用于只使用 MiraiCP 插件的项目, 无需下载 mcl
- MiraiCP-core 直接启动 Mirai(实验性特性)
- 进行下一步
- 从MiraiCP-template 中下载 适用于 MiraiCP-plugin 和 MiraiCP-loader 的插件模板, 或者从MiraiCP-core-demo 中下载适用于 MiraiCP-core 的插件模板(请不要向该模板仓库提issue!)
- 如果是 MiraiCP-core 项目, 跳转至启动 MiraiCP-core(实验性内容)
- 在
main.cpp
中编写, 并编译出动态链接库(通常后缀为.dll
/.so
) - 进行下一步, 启动和配置 MiraiCP, 跳转至启动 MiraiCP-plugin或启动 MiraiCP-loader
-
确保本地已经下载 Mirai-Console-Loader 并可以启动, 如果没有, 跳转至Mirai-Console-Loader
-
在 mcl 目录下输入
mcl --update-package io.github.nambers:MiraiCP-plugin --channel nightly --type plugin
让 mcl 自动下载, 或者从本项目release
中下载最新的MiraiCP-plugin-<version>.mirai.jar
放置到 mcl 下的 plugin 文件夹 -
在 mcl 下的
data/tech.eritquearcus.miraicp
里更改配置文件, 大概长这样: 里面的 path 就是3.1节编译出来的{ "pluginConfig":[{ "path":"\\cmake-build-debug\\MiraiCP.dll" }] }
详细配置见 doc
-
进行下一步, 下载中间件
- 确保本地有 jdk 环境
- 在本项目
release
中下载最新的MiraiCP-loader-<version>.jar
- 在该 jar 同目录下创建
config.json
作为配置文件 - 编写json:
详细见config.md文档
{ "accounts": [{ "id": qqid, "passwords": "passwords密码", "protocol": "pad", "heatBeat": "STAT_HB", "md5": false, "autoLogin": true }], "cppPaths": [ {"path": "dll路径"} ] }
- 进行下一步, 下载中间件
- 确保本地有 jdk 环境
- 从本项目 release 中下载
MiraiCP-core-<version>.jar
, 放置到一个你知道的目录 - 在
main.cpp
中把上面 jar 的目录写入(load
方法内) - 直接运行
main
方法
-
确保已经完成了上面的下载启动器, MiraiCP-core 可跳过本阶段
-
从最新的 release 中下载
libLoader-<version>
对应自己操作系统的中间件libLoader. libLoader是用于管理插件运行时动态链接的工具,提供热重载等功能。libLoader的详细工作原理见文档 名字对照表见下表格Platform Name Libloader name Windows libloader-<version>.dll Linux libloader-<version>.so 如果上面没有你的版本, 可以发 issue 以获取支持, 或者自行编译 libLoader -
把 libloader 放在 3.2节 下载的启动器的同目录下, 或者在配置文件里的
advanceConfig
下的libLoaderPath
配置项写入 libLoader 的绝对路径包含扩展名 -
使用
java -jar MiraiCP-loader-<version>.jar
启动 MiraiCP-loader 或 启动 mcl 以启动 MiraiCP-plugin
如果有其他问题,欢迎提交issue和提交PR贡献
可直接在模板clone
下来的文件夹中git stash
, git fetch
, git pull
, git stash pop
直接从上游拉取代码, 然后再在本项目的release
中下载最新对应的jar组件和中间件替换旧的
-
从最新release 中下载loader/plugin/core的jar文件和中间件并替换
-
从各自的模板项目中下载
MiraiCP.hpp
,MiraiCP.cpp
, 以及如果是MiraiCP-core
项目的core.h
,core.cpp
, 替换原本的文件
论坛贴: miraicp
github issue: miraicp issue
qq群: 1044565129
查看 issues
Copyright (C) 2020-2022 Eritque arcus and contributors.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or any later version(in your opinion).
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Dependence name | Url | Author | License |
---|---|---|---|
JSON for modern C++ | https://github.com/nlohmann/json | Niels Lohmann | MIT |
UTF8-CPP: UTF-8 with C++ in a Portable Way | https://github.com/nemtrif/utfcpp | Nemanja Trifunovic | BSL-1.0 |
JNI Headers | Null | Java | GNU General Public License version 2 |