-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathircbot.hpp
68 lines (64 loc) · 2.02 KB
/
ircbot.hpp
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
/*
* IRCBot - An IRC relay for the Yogstation Discord.
* Copyright (C) 2016 Yogstation13
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef IRCBOT_HPP
#define IRCBOT_HPP
#include <QObject>
#include <QDiscord/QDiscord/QDiscord>
#include <QDir>
#include <QFile>
#include "ircserver.hpp"
class IrcBot : public QObject
{
Q_OBJECT
public:
explicit IrcBot(QObject* parent = 0);
void addBan(const QString& ban);
void removeBan(const QString& ban);
private:
void loadConfig();
void loadBanlist();
void discordLogin();
void discordLoginFinished();
void discordLoginFailed();
void discordGuildAvailable(QDiscordGuild* guild);
void discordMessageCreated(QDiscordMessage message);
void createDefaultConfig();
QJsonObject currentConfigToObject();
void setCurrentConfigToObject(const QJsonObject& object);
void ircClientConnected(IrcClient* client);
void ircClientDisconnected(IrcClient* client);
void ircClientMessageReceived(IrcClient* client, QString message);
static QString makeValidNick(QString nick);
static QChar makeValidChar(QChar c);
QDiscord _discord;
QStringList _banlist;
IrcServer _server;
static const QString _configPath;
static const QString _banlistPath;
QDiscordChannel* _publicChannel;
QString _loginToken;
QString _publicChannelId;
QString _guildId;
QString _password;
QString _hostname;
QString _motd;
QString _serverName;
int _port;
bool _announceConnections;
};
#endif // IRCBOT_HPP