-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathevent_handler.cpp
78 lines (54 loc) · 2.48 KB
/
event_handler.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "event_handler.h"
using namespace std;
using namespace google::protobuf;
namespace EventHandler {
void handlePrivateMessageEvent(const shared_ptr<Bot> &bot,
const PrivateMessageEvent &event) {
auto resp = bot->sendPrivateMsg(event.user_id(), "1", false);
cout << resp->message_id() << endl;
}
void handleGroupMessageEvent(const shared_ptr<Bot> &bot,
const GroupMessageEvent &event) {
// 如果消息内容是 "hi",发送语音 "hello",5秒后撤回
if ("hi" == event.raw_message()) {
auto msg = Tts("hello");
auto resp = bot->sendGroupMsg(event.group_id(), msg, false);
this_thread::sleep_for(5000ms);
bot->deleteMsg(resp->message_id());
}
}
void handleGroupUploadNoticeEvent(const shared_ptr<Bot> &bot,
const GroupUploadNoticeEvent &event) {
}
void handleGroupAdminNoticeEvent(const shared_ptr<Bot> &bot,
const GroupAdminNoticeEvent &event) {
}
void handleGroupDecreaseNoticeEvent(const shared_ptr<Bot> &bot,
const GroupDecreaseNoticeEvent &event) {
}
void handleGroupIncreaseNoticeEvent(const shared_ptr<Bot> &bot,
const GroupIncreaseNoticeEvent &event) {
}
void handleGroupBanNoticeEvent(const shared_ptr<Bot> &bot,
const GroupBanNoticeEvent &event) {
}
void handleFriendAddNoticeEvent(const shared_ptr<Bot> &bot,
const FriendAddNoticeEvent &event) {
}
void handleGroupRecallNoticeEvent(const shared_ptr<Bot> &bot,
const GroupRecallNoticeEvent &event) {
}
void handleFriendRecallNoticeEvent(const shared_ptr<Bot> &bot,
const FriendRecallNoticeEvent &event) {
}
void handleFriendRequestEvent(const shared_ptr<Bot> &bot,
const FriendRequestEvent &event) {
// 同意所有好友
// bot->setFriendAddRequest(event.flag(), true, "ok");
}
void handleGroupRequestEvent(const shared_ptr<Bot> &bot,
const GroupRequestEvent &event) {
// 拒绝所有加群请求
// bot->setGroupAddRequest(event.flag(), event.sub_type(), event.post_type(), false, "no");
}
}