@@ -26,66 +26,78 @@ int main()
2626
2727 bot.On <MemberMuteEvent>([&](MemberMuteEvent e)
2828 {
29+ // 机器人的操作不做处理
30+ if (e.OperatorIsBot ())
31+ {
32+ cout << " 机器人禁言操作" << endl;
33+ return ;
34+ }
2935 auto mc = MessageChain ()
3036 .Plain (" 恭喜老哥 " + e.Member .MemberName + " 喜提禁言套餐!" );
3137 bot.SendMessage (e.Member .Group .GID , mc);
3238 });
3339
3440 bot.On <MemberUnmuteEvent>([&](MemberUnmuteEvent e)
3541 {
42+ // 机器人的操作不做处理
43+ if (e.OperatorIsBot ())
44+ {
45+ cout << " 机器人解除禁言操作" << endl;
46+ return ;
47+ }
3648 auto mc = MessageChain ()
3749 .Plain (" 恭喜老哥 " + e.Member .MemberName + " 提前出狱!" );
3850 bot.SendMessage (e.Member .Group .GID , mc);
3951 });
4052
41- bool res = false ;
42- res = bot.MuteAll (1029259687_gid);
43- if (res)
53+ try
4454 {
55+ bot.MuteAll (1029259687_gid);
4556 cout << " 全体禁言成功!" << endl;
4657 }
47- else
58+ catch ( const exception& ex)
4859 {
49- cout << " 全体禁言失败" << endl;
60+ cout << " 全体禁言失败: " << ex. what () << endl;
5061 }
5162
63+
5264 MiraiBot::SleepSeconds (5 );
5365
54- res = bot.UnMuteAll (1029259687_gid);
55- if (res)
66+ try
5667 {
68+ bot.UnMuteAll (1029259687_gid);
5769 cout << " 解除全体禁言成功!" << endl;
5870 }
59- else
71+ catch ( const exception& ex)
6072 {
61- cout << " 解除全体禁言失败" << endl;
73+ cout << " 解除全体禁言失败: " << ex. what () << endl;
6274 }
6375
64- res = bot.Mute (1029259687_gid, 211795583_qq, 60 );
65- if (res)
76+ try
6677 {
67- cout << " 禁言群员成功!" << endl;
78+ bot.Mute (1029259687_gid, 211795583_qq, 60 );
79+ cout << " 禁言群成员成功!" << endl;
6880 }
69- else
81+ catch ( const exception& ex)
7082 {
71- cout << " 禁言群员失败 " << endl;
83+ cout << " 禁言群成员失败: " << ex. what () << endl;
7284 }
7385
86+
7487 MiraiBot::SleepSeconds (5 );
7588
76- res = bot.UnMute (1029259687_gid, 211795583_qq);
77- if (res)
89+ try
7890 {
79- cout << " 解除禁言群员成功!" << endl;
91+ bot.UnMute (1029259687_gid, 211795583_qq);
92+ cout << " 解除禁言群成员成功!" << endl;
8093 }
81- else
94+ catch ( const exception& ex)
8295 {
83- cout << " 解除禁言群员失败 " << endl;
96+ cout << " 解除禁言群成员失败: " << ex. what () << endl;
8497 }
8598
8699
87100 bot.EventLoop ();
88101
89-
90102 return 0 ;
91103}
0 commit comments