This repository has been archived by the owner on Jun 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
modules.cpp
131 lines (98 loc) · 4.5 KB
/
modules.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include "core.h"
#include "mirai/api.h"
#include "app/data/user.h"
#include "app/data/group.h"
#include "app/case.h"
#include "app/help.h"
#include "app/tools.h"
#include "app/smoke.h"
#include "app/eatwhat.h"
#include "app/monopoly.h"
#include "app/weather.h"
#include "app/gambol.h"
#include "app/apievent.h"
#include "app/playwhat.h"
#include "app/api/api.h"
#include "time_evt.h"
// #include "app/event_case.h"
// #include "app/gambol.h"
// #include "app/user_op.h"
// #include "app/weather.h"
namespace core
{
void init_modules()
{
// app: api
::bbb::api::inst.init("./config/apikey.yaml");
// app: case
opencase::init("./config/case.yaml");
// app: event_case
// event_case::init("./app/event_case_draw.yaml", "./app/eent_case_drop.yaml");
// app: eat
eatwhat::init();
addTimedEventEveryMin(std::bind(&SQLite::commit, &eatwhat::db, true));
// eat::updateSteamGameList();
// app: monopoly
// mnp::calc_event_max();
monopoly::init("./config/monopoly_chance.yaml");
// app: weather
weather::init("./config/weather.yaml");
// app: playwhat
playwhat::updateSteamGameList();
addTimedEvent(playwhat::updateSteamGameList, 0, 0);
// app: gambol
gambol::roulette::refreshStock(30000, false);
addTimedEvent([](){ gambol::roulette::refreshStock(30000, true); }, 12, 0);
// announce startup
// std::string boot_info = help::boot_info();
// broadcastMsg(boot_info.c_str(), grp::MASK_BOOT_ANNOUNCE);
}
void shutdown_modules()
{
gambol::flipcoin::roundCancelAll();
gambol::roulette::roundCancelAll();
monopoly::StopDrawing();
eatwhat::db.transactionStop();
}
void add_timed_events()
{
// 每天刷新群名片
for (auto it = grp::groups.begin(); it != grp::groups.end(); ++it)
addTimedEvent(std::bind(&grp::Group::updateMembers, &it->second), 0, 0);
// 每天刷批
user::daily_refresh_time = time(nullptr) - 60 * 60 * 24; // yesterday
user::daily_refresh_tm_auto = *localtime(&user::daily_refresh_time);
addTimedEvent(std::bind(user::flushDailyTimep, true), user::NEW_DAY_TIME_HOUR, user::NEW_DAY_TIME_MIN);
/*
%%%%%%%% steam game list %%%%%%%%
addTimedEvent([&]() { eat::updateSteamGameList(); }, 0, 0);
%%%%%%%% 下午6点活动开箱 %%%%%%%%
addTimedEvent([&]() { event_case::startEvent(); }, event_case::EVENT_CASE_TIME_HOUR_START, event_case::EVENT_CASE_TIME_MIN_START);
addTimedEvent([&]() { event_case::stopEvent(); }, event_case::EVENT_CASE_TIME_HOUR_END, event_case::EVENT_CASE_TIME_MIN_END);
*/
}
void add_msg_callbacks()
{
using evt = mirai::RecvMsgType;
mirai::regEventProc(evt::NewFriendRequestEvent, {"apievent::NewFriendRequestEvent", apievent::NewFriendRequestEvent});
mirai::regEventProc(evt::GroupMessage, {"opencase::msgDispatcher", opencase::msgDispatcher});
mirai::regEventProc(evt::FriendMessage, {"help::msgDispatcher", help::msgDispatcher});
mirai::regEventProc(evt::TempMessage, {"help::msgDispatcher", help::msgDispatcher});
mirai::regEventProc(evt::GroupMessage, {"help::msgDispatcher", help::msgDispatcher});
mirai::regEventProc(evt::FriendMessage, {"tools::msgDispatcher", tools::msgDispatcher});
mirai::regEventProc(evt::TempMessage, {"tools::msgDispatcher", tools::msgDispatcher});
mirai::regEventProc(evt::GroupMessage, {"tools::msgDispatcher", tools::msgDispatcher});
mirai::regEventProc(evt::FriendMessage, {"smoke::privateMsgCallback", smoke::privateMsgCallback});
mirai::regEventProc(evt::TempMessage, {"smoke::privateMsgCallback", smoke::privateMsgCallback});
mirai::regEventProc(evt::GroupMessage, {"smoke::groupMsgCallback", smoke::groupMsgCallback});
mirai::regEventProc(evt::MemberMuteEvent, {"smoke::MemberMuteEvent", smoke::MemberMuteEvent});
mirai::regEventProc(evt::MemberUnmuteEvent, {"smoke::MemberUnmuteEvent", smoke::MemberUnmuteEvent});
mirai::regEventProc(evt::GroupMessage, {"eatwhat::msgDispatcher", eatwhat::msgDispatcher});
mirai::regEventProc(evt::GroupMessage, {"monopoly::msgCallback", monopoly::msgCallback});
mirai::regEventProc(evt::FriendMessage, {"weather::msgCallback", weather::msgCallback});
mirai::regEventProc(evt::TempMessage, {"weather::msgCallback", weather::msgCallback});
mirai::regEventProc(evt::GroupMessage, {"weather::msgCallback", weather::msgCallback});
mirai::regEventProc(evt::GroupMessage, {"gambol::msgDispatcher", gambol::msgDispatcher});
mirai::regEventProc(evt::GroupMessage, {"playwhat::msgDispatcher", playwhat::msgCallback});
}
}