-
Notifications
You must be signed in to change notification settings - Fork 0
/
botengine.h
104 lines (65 loc) · 2.08 KB
/
botengine.h
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
#ifndef BOTENGINE_H
#define BOTENGINE_H
#include <random>
#include <QObject>
#include <QString>
#include <QTime>
#include <QTimer>
#include <QMap>
#include <QRegExp>
#include <QList>
#include <QCryptographicHash>
#include "ircmsgparser.h"
#include "simplexmlreadwrite.h"
#include "twitchapi.h"
#include "random.h"
#include "settings.h"
class BotEngine : public QObject
{
Q_OBJECT
typedef void (BotEngine::* fnPtr)(const IRCMsgParser::IRCMsg & msg);
private:
struct CommandInfo {
fnPtr fn_ptr;
size_t minDelayMsec;
qint64 currentDelayMsec;
bool isOn;
bool isCustom;
QString customCmdMessage;
int repeatDelay;
};
static const char specialSymbol = '!';
static const int defaultMinDelayMsec = 5000;
QMap<QString, CommandInfo> commandList;
QTimer repeatMsgTimer;
QString repeatMsg;
bool greetSubs;
QString greetingMsg;
QString cur_channel;
public:
explicit BotEngine(QObject *parent = 0);
~BotEngine();
void update_single_cmd_settings(const QString & command);
void set_cur_channel(const QString & channel);
void set_subs_greeting_state(bool state);
void set_subs_greeting_msg(const QString & msg);
void start_repeating_message(const QString & msg, int repeatTimeSec);
void stop_repeating_message();
void parseNewMsg(const IRCMsgParser::IRCMsg & msg);
private:
void processTwitchNotifyMsg(const IRCMsgParser::IRCMsg & msg);
void showSubGreetingMsg(const IRCMsgParser::IRCMsg & msg);
QString get_command(const QString & text);
QString processCustomMessage(const IRCMsgParser::IRCMsg & msg);
void showCustomMessage(const IRCMsgParser::IRCMsg & msg);
/* Build-in Commands */
void showDongSize(const IRCMsgParser::IRCMsg & msg);
void showUptime(const IRCMsgParser::IRCMsg & msg);
void showStreamDelay(const IRCMsgParser::IRCMsg & msg);
void showFollowTime(const IRCMsgParser::IRCMsg & msg);
signals:
void botMessageReady(const QString & msg);
public slots:
void onRepeatTimerTimeout();
};
#endif // BOTENGINE_H