@@ -54,38 +54,32 @@ cd vcpkg
5454
5555``` powershell
5656git clone https://github.com/cyanray/mirai-cpp-vcpkg-port.git tmp ; rm -Recurse -Force ports/mirai-cpp ; mv tmp/* ports/ ; rm -Recurse -Force tmp
57- ./vcpkg install mirai-cpp
58- # 如果你要构建 x64 平台的程序,需要执行:
59- # ./vcpkg install mirai-cpp:x64-windows
57+ ./vcpkg install mirai-cpp mirai-cpp:x64-windows
6058```
6159
62- 耐心等待,上面的代码会帮你安装 mirai-cpp 以及它的依赖项目。
60+ 耐心等待,上面的指令会帮你安装 mirai-cpp 以及它的依赖项目。
6361
6462#### (3) 在 ** Visual Studio** 中创建一个项目,开始使用
6563
6664尝试以下代码:
6765
6866``` c++
6967#include < iostream>
70- #include < mirai.hpp >
68+ #include < mirai.h >
7169
7270int main ()
7371{
7472 using namespace std;
7573 using namespace Cyan;
76- MiraiBot bot;
74+ MiraiBot bot("127.0.0.1",8080) ;
7775 while (true)
7876 {
7977 try
8078 {
8179 // InitKeyVl0CEUzZ 改为你的 InitKey,
8280 // 2110000000 改为你的 bot 的 QQ 号码
83- // 提示: mirai-cpp 不支持隐式地将字面数字转化为 QQ_t 或 GID_t
84- // 你需要给字面数字添加后缀 qq 或 _qq (gid 或 _gid), 将字面数字转化为 QQ_t (GID_t)
85- // 如果想将 QQ_t(GID_t) 转化为数字,可以使用强制类型转换:
86- // QQ_t qq = 10001_qq;
87- // int64_t qq_num = (int64_t)(qq);
88- bot.Auth("InitKeyVl0CEUzZ", 2110000000qq);
81+ // 提示: mirai-cpp 中,数字后面加上 _qq 表示 qq 号码,数字后面加上 _gid 表示群号码。
82+ bot.Auth("InitKeyVl0CEUzZ", 2110000000_qq);
8983 break;
9084 }
9185 catch (const std::exception & ex)
@@ -97,17 +91,17 @@ int main()
9791
9892
9993 bot.On<FriendMessage>(
100- [&](FriendMessage fm )
94+ [&](FriendMessage m )
10195 {
10296 // bot.SendFriendMessage(fm.Sender.QQ, fm.MessageChain);
103- fm .Reply(fm .MessageChain);
97+ m .Reply(m .MessageChain);
10498 });
10599
106100 bot.On<GroupMessage>(
107- [&](GroupMessage gm )
101+ [&](GroupMessage m )
108102 {
109103 // bot.SendGroupMessage(gm.Sender.Group.GID, "为什么要 " + gm.MessageChain);
110- gm .QuoteReply("为什么要 " + gm .MessageChain);
104+ m .QuoteReply("为什么要 " + m .MessageChain);
111105 });
112106
113107 bot.EventLoop();
@@ -138,24 +132,75 @@ MSVC 并没有默认启动对 UTF-8 编码的支持。
138132
139133</details >
140134
141- ### 2. 其他使用方式
135+
136+
137+ ### 2. 快速尝试2
138+
139+ <details >
140+
141+ #### (1) 安装 ** vcpkg** (如果你已经安装则可以略过)
142+
143+ 1 . 打开 Powershell ,找到一个合适的位置,执行以下命令:
144+
145+ ``` powershell
146+ git clone https://github.com/Microsoft/vcpkg.git
147+ cd vcpkg
148+ .\bootstrap-vcpkg.bat
149+ ```
150+
151+ 2 . 如果上面的代码执行无误,那么 ** vcpkg** 已经成功编译。执行下面的命令让 ** Visual Studio 2019** 与 ** vcpkg** 相关联
152+
153+ ``` powershell
154+ .\vcpkg integrate install
155+ ```
156+
157+ #### (2) 使用 ** vcpkg** 安装 ** mirai-cpp** 的依赖项目
158+
159+ ``` powershell
160+ ./vcpkg install nlohmann-json curl boost-asio
161+ ```
162+
163+ 耐心等待,上面的指令会帮你安装 mirai-cpp 的依赖项目。
164+
165+ #### (3) 直接开始体验 mirai-cpp
166+
167+ 将本仓库克隆到合适的位置
168+
169+ ``` powershell
170+ git clone https://github.com/cyanray/mirai-cpp.git
171+ ```
172+
173+ 如果一切顺利,你已经将本仓库的所有内容克隆到了 mirai-cpp 文件夹里。
174+
175+ 如图所示,使用 Visual Studio 2019 直接打开这个文件夹。
176+
177+ ![ 使用 VS 直接打开 mirai-cpp 文件夹] ( ./doc/pic/vs.png )
178+
179+ 之后,需要设置一下 CMake Toolchain File,按照图中的步骤操作。
180+
181+ ![ 设置 CMake] ( ./doc/pic/vs2.png )
182+
183+ 如果一切顺利,你就可以直接运行我写好的示例。
184+
185+ ![ 开始运行 examples] ( ./doc/pic/vs3.png )
186+
187+ </details >
188+
189+ ### 3. 其他使用方式
142190
143191#### (1) 更新 mirai-cpp
144192
145193在更新 mirai-cpp 之前,需要先删除已经安装的 mirai-cpp
146194
147195``` powershell
148- ./vcpkg remove mirai-cpp
149- ./vcpkg remove mirai-cpp:x64-windows # 如果有安装 mirai-cpp:x64-windows
196+ ./vcpkg remove mirai-cpp mirai-cpp:x64-windows
150197```
151198
152199删除之后,重新安装即可:
153200
154201``` powershell
155202git clone https://github.com/cyanray/mirai-cpp-vcpkg-port.git tmp ; rm -Recurse -Force ports/mirai-cpp ; mv tmp/* ports/ ; rm -Recurse -Force tmp
156- ./vcpkg install mirai-cpp
157- # 如果你要构建 x64 平台的程序,需要执行:
158- # ./vcpkg install mirai-cpp:x64-windows
203+ ./vcpkg install mirai-cpp mirai-cpp:x64-windows
159204```
160205
161206## 代码风格
0 commit comments