diff --git a/bin/config_sample/discord.ini b/bin/config_sample/discord.ini index 83c41ac..6fb6bc3 100644 --- a/bin/config_sample/discord.ini +++ b/bin/config_sample/discord.ini @@ -20,14 +20,5 @@ webhook_ban_enabled = false ; The URL of the ban discord webhook to send messages to. Must contain the webhook ID and token. webhook_ban_url= -; Enables Uptime Webhook. -webhook_uptime_enabled = false - -; The time between message posting. Time is in minutes. -webhook_uptime_time = 60 - -; The URL of the Uptime Webhook. Must contain the webhook ID and token. -webhook_uptime_url= - ; The color code for the webhook. Allows customization of the color used in the embeed. webhook_color= diff --git a/src/config_manager.cpp b/src/config_manager.cpp index 92a286a..a9bbc76 100644 --- a/src/config_manager.cpp +++ b/src/config_manager.cpp @@ -25,7 +25,6 @@ QSettings *ConfigManager::m_areas = new QSettings("config/areas.ini", QSettings: QSettings *ConfigManager::m_logtext = new QSettings("config/text/logtext.ini", QSettings::IniFormat); QSettings *ConfigManager::m_ambience = new QSettings("config/ambience.ini", QSettings::IniFormat); ConfigManager::CommandSettings *ConfigManager::m_commands = new CommandSettings(); -QElapsedTimer *ConfigManager::m_uptimeTimer = new QElapsedTimer; MusicList *ConfigManager::m_musicList = new MusicList; QHash *ConfigManager::m_commands_help = new QHash; QStringList *ConfigManager::m_ordered_list = new QStringList; @@ -98,8 +97,6 @@ bool ConfigManager::verifyServerConfig() if (m_commands->cdns.isEmpty()) m_commands->cdns = QStringList{"cdn.discord.com"}; - m_uptimeTimer->start(); - return true; } @@ -506,27 +503,6 @@ QString ConfigManager::discordBanWebhookUrl() return m_discord->value("Discord/webhook_ban_url", "").toString(); } -bool ConfigManager::discordUptimeEnabled() -{ - return m_discord->value("Discord/webhook_uptime_enabled", "false").toBool(); -} - -int ConfigManager::discordUptimeTime() -{ - bool ok; - int l_aliveTime = m_discord->value("Discord/webhook_uptime_time", "60").toInt(&ok); - if (!ok) { - qWarning("alive_time is not an int"); - l_aliveTime = 60; - } - return l_aliveTime; -} - -QString ConfigManager::discordUptimeWebhookUrl() -{ - return m_discord->value("Discord/webhook_uptime_url", "").toString(); -} - QString ConfigManager::discordWebhookColor() { const QString l_default_color = "13312842"; @@ -657,11 +633,6 @@ bool ConfigManager::advertiseWSProxy() return m_settings->value("Advertiser/cloudflare_enabled", "false").toBool(); } -qint64 ConfigManager::uptime() -{ - return m_uptimeTimer->elapsed(); -} - ConfigManager::help ConfigManager::commandHelp(QString f_command_name) { return m_commands_help->value(f_command_name); diff --git a/src/config_manager.h b/src/config_manager.h index 888e6ba..a971552 100644 --- a/src/config_manager.h +++ b/src/config_manager.h @@ -311,23 +311,6 @@ class ConfigManager */ static QString discordBanWebhookUrl(); - /** - * @brief Returns if the Webhook sends an alive message. - */ - static bool discordUptimeEnabled(); - - /** - * @brief Returns the time between posting. - */ - static int discordUptimeTime(); - - /** - * @brief Returns the Discord Uptime Webhook URL. - * - * @return See short description. - */ - static QString discordUptimeWebhookUrl(); - /** * @brief Returns a user configurable color code for the embeed object.s * @@ -464,11 +447,6 @@ class ConfigManager */ static bool advertiseWSProxy(); - /** - * @brief Returns the uptime of the server in miliseconds. - */ - static qint64 uptime(); - /** * @brief A struct that contains the help information for a command. * It's split in the syntax and the explanation text. @@ -567,11 +545,6 @@ class ConfigManager */ static QSettings *m_ambience; - /** - * @brief Pointer to QElapsedTimer to track the uptime of the server. - */ - static QElapsedTimer *m_uptimeTimer; - /** * @brief Contains the musiclist with time durations. */ diff --git a/src/discord.cpp b/src/discord.cpp index 806dd1a..4650152 100644 --- a/src/discord.cpp +++ b/src/discord.cpp @@ -25,10 +25,6 @@ Discord::Discord(QObject *parent) : m_nam = new QNetworkAccessManager(); connect(m_nam, &QNetworkAccessManager::finished, this, &Discord::onReplyFinished); - - m_uptimePostTimer = new QTimer; - connect(m_uptimePostTimer, &QTimer::timeout, - this, &Discord::onUptimeWebhookRequested); } void Discord::onModcallWebhookRequested(const QString &f_name, const QString &f_area, const QString &f_reason, const QQueue &f_buffer) @@ -50,19 +46,6 @@ void Discord::onBanWebhookRequested(const QString &f_ipid, const QString &f_mode postJsonWebhook(l_json); } -void Discord::onUptimeWebhookRequested() -{ - qint64 l_expiredTimeSeconds = ConfigManager::uptime() / 1000; - int minutes = (l_expiredTimeSeconds / 60) % 60; - int hours = (l_expiredTimeSeconds / (60 * 60)) % 24; - int days = (l_expiredTimeSeconds / (60 * 60 * 24)) % 365; - - m_request.setUrl(QUrl(ConfigManager::discordUptimeWebhookUrl())); - QString f_timeExpired = QString::number(days) + " days, " + QString::number(hours) + " hours and " + QString::number(minutes) + " minutes."; - QJsonDocument l_json = constructUptimeJson(f_timeExpired); - postJsonWebhook(l_json); -} - QJsonDocument Discord::constructModcallJson(const QString &f_name, const QString &f_area, const QString &f_reason) const { QJsonObject l_json; @@ -94,20 +77,6 @@ QJsonDocument Discord::constructBanJson(const QString &f_ipid, const QString &f_ return QJsonDocument(l_json); } -QJsonDocument Discord::constructUptimeJson(const QString &f_timeExpired) -{ - QJsonObject l_json; - QJsonArray l_array; - QJsonObject l_object{ - {"color", ConfigManager::discordWebhookColor()}, - {"title", "Your server is online!"}, - {"description", "Your server has been online for " + f_timeExpired}}; - l_array.append(l_object); - l_json["embeds"] = l_array; - - return QJsonDocument(l_json); -} - QHttpMultiPart *Discord::constructLogMultipart(const QQueue &f_buffer) const { QHttpMultiPart *l_multipart = new QHttpMultiPart(); @@ -160,14 +129,3 @@ Discord::~Discord() { m_nam->deleteLater(); } - -void Discord::startUptimeTimer() -{ - m_uptimePostTimer->start(ConfigManager::discordUptimeTime() * 60000); - onUptimeWebhookRequested(); -} - -void Discord::stopUptimeTimer() -{ - m_uptimePostTimer->stop(); -} diff --git a/src/discord.h b/src/discord.h index 92fd894..1a10f56 100644 --- a/src/discord.h +++ b/src/discord.h @@ -79,11 +79,6 @@ class Discord : public QObject */ void onBanWebhookRequested(const QString &f_ipid, const QString &f_moderator, const QString &f_duration, const QString &f_reason, const int &f_banID); - /** - * @brief Handles a uptime webhook request. - */ - void onUptimeWebhookRequested(); - private: /** * @brief The QNetworkAccessManager for webhooks. @@ -95,11 +90,6 @@ class Discord : public QObject */ QNetworkRequest m_request; - /** - * @brief Timer to post a message that the server is still alive. - */ - QTimer *m_uptimePostTimer; - /** * @brief Constructs a new JSON document for modcalls. * @@ -153,13 +143,6 @@ class Discord : public QObject * @return A JSON document for the ban. */ QJsonDocument constructBanJson(const QString &f_ipid, const QString &f_moderator, const QString &f_duration, const QString &f_reason, const int &f_banID); - /** - * @brief Constructs a new JSON document for the server alive message. - * @param f_timeExpired formatted uptime as a string. - * - * @return A JSON document for the alive notification. - */ - QJsonDocument constructUptimeJson(const QString &f_timeExpired); }; #endif // DISCORD_H diff --git a/src/packet/packet_ma.cpp b/src/packet/packet_ma.cpp index c013ae5..5a0f86c 100644 --- a/src/packet/packet_ma.cpp +++ b/src/packet/packet_ma.cpp @@ -20,6 +20,8 @@ PacketInfo PacketMA::getPacketInfo() const void PacketMA::handlePacket(AreaData *area, AOClient &client) const { + Q_UNUSED(area); + if (!client.m_authenticated) { client.sendServerMessage("You are not logged in!"); return; diff --git a/src/server.cpp b/src/server.cpp index 80db537..60908a3 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -496,11 +496,6 @@ void Server::handleDiscordIntegration() if (ConfigManager::discordBanWebhookEnabled()) connect(this, &Server::banWebhookRequest, discord, &Discord::onBanWebhookRequested); - - if (ConfigManager::discordUptimeEnabled()) - discord->startUptimeTimer(); - else - discord->stopUptimeTimer(); } return; }