This repository has been archived by the owner on Jan 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.cpp
80 lines (68 loc) · 1.42 KB
/
app.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
79
80
#include "./app.h"
#include "./api.h"
#include "./def.h"
#include "./utils/function.h"
namespace cq {
Config config;
namespace app {
int32_t auth_code = 0;
std::function<void()> on_initialize;
std::function<void()> on_enable;
std::function<void()> on_disable;
std::function<void()> on_coolq_start;
std::function<void()> on_coolq_exit;
std::function<void()> __main;
} // namespace app
} // namespace cq
using namespace std;
using namespace cq;
using cq::utils::call_if_valid;
/**
* Return app info.
*/
__CQ_EVENT(const char *, AppInfo, 0)
() {
return "9," APP_ID; // APP_ID is from CMakeLists.txt
}
/**
* Initialize SDK using the auth code given by CoolQ.
*/
__CQ_EVENT(int32_t, Initialize, 4)
(const int32_t auth_code) {
app::auth_code = auth_code;
api::__init();
call_if_valid(app::on_initialize);
return 0;
}
/**
* Event: Plugin is enabled.
*/
__CQ_EVENT(int32_t, cq_app_enable, 0)
() {
call_if_valid(app::on_enable);
return 0;
}
/**
* Event: Plugin is disabled.
*/
__CQ_EVENT(int32_t, cq_app_disable, 0)
() {
call_if_valid(app::on_disable);
return 0;
}
/**
* Event: CoolQ is starting.
*/
__CQ_EVENT(int32_t, cq_coolq_start, 0)
() {
call_if_valid(app::on_coolq_start);
return 0;
}
/**
* Event: CoolQ is exiting.
*/
__CQ_EVENT(int32_t, cq_coolq_exit, 0)
() {
call_if_valid(app::on_coolq_exit);
return 0;
}