This repository was archived by the owner on Aug 16, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +28
-15
lines changed Expand file tree Collapse file tree 2 files changed +28
-15
lines changed Original file line number Diff line number Diff line change @@ -13,16 +13,15 @@ int main(int argc, char* argv[])
1313 bot.Connect (opts);
1414 cout << " Bot working..." << endl;
1515
16- FriendImage img = bot.UploadFriendImage (" D:\\ test.png" );
17- GroupImage gImg = bot.UploadGroupImage (" D:\\ test.png" );
18- TempImage tImg = bot.UploadTempImage (" D:\\ test.png" );
16+ string ImagePath (" E:/test.png" );
1917
2018 bot.On <FriendMessage>(
21- [&](FriendMessage fm )
19+ [&](FriendMessage m )
2220 {
2321 try
2422 {
25- fm.Reply (MessageChain ().Image (img));
23+ FriendImage img = bot.UploadFriendImage (ImagePath);
24+ m.Reply (MessageChain ().Image (img));
2625 }
2726 catch (const std::exception& ex)
2827 {
@@ -31,11 +30,12 @@ int main(int argc, char* argv[])
3130 });
3231
3332 bot.On <GroupMessage>(
34- [&](GroupMessage gm )
33+ [&](GroupMessage m )
3534 {
3635 try
3736 {
38- bot.SendMessage (gm.Sender .Group .GID , MessageChain ().Image (gImg ));
37+ GroupImage gImg = bot.UploadGroupImage (ImagePath);
38+ bot.SendMessage (m.Sender .Group .GID , MessageChain ().Image (gImg ));
3939 }
4040 catch (const std::exception& ex)
4141 {
@@ -44,11 +44,12 @@ int main(int argc, char* argv[])
4444 });
4545
4646 bot.On <TempMessage>(
47- [&](TempMessage gm )
47+ [&](TempMessage m )
4848 {
4949 try
5050 {
51- gm.Reply (MessageChain ().Image (tImg));
51+ TempImage tImg = bot.UploadTempImage (ImagePath);
52+ m.Reply (MessageChain ().Image (tImg));
5253 }
5354 catch (const std::exception& ex)
5455 {
Original file line number Diff line number Diff line change @@ -79,14 +79,26 @@ namespace Cyan
7979 }
8080 virtual json ToJson () const override
8181 {
82- return
82+ json result =
8383 {
84- { " type" , GetType () },
85- { " imageId" , imageId_ },
86- { " url" , url_ },
87- { " path" , path_ },
88- { " base64" , base64_ }
84+ { " type" , GetType () }
8985 };
86+ imageId_.empty ()
87+ ? result[" imageId" ] = json (nullptr )
88+ : result[" imageId" ] = imageId_;
89+
90+ url_.empty ()
91+ ? result[" url" ] = json (nullptr )
92+ : result[" url" ] = url_;
93+
94+ path_.empty ()
95+ ? result[" path" ] = json (nullptr )
96+ : result[" path" ] = path_;
97+
98+ base64_.empty ()
99+ ? result[" base64" ] = json (nullptr )
100+ : result[" base64" ] = base64_;
101+ return result;
90102 }
91103 virtual ~ImageMessage () {}
92104
You can’t perform that action at this time.
0 commit comments