emit most log slots from AOClient

- Still need to figure out how login handles it
This commit is contained in:
Salanto 2021-08-25 05:34:16 +02:00
parent bc5ec9fa9d
commit 70a63dd8b3
5 changed files with 23 additions and 13 deletions

View File

@ -2228,13 +2228,12 @@ class AOClient : public QObject {
/** /**
* @brief Signal connected to universal logger. Sends player kick information to the logger. * @brief Signal connected to universal logger. Sends player kick information to the logger.
*/ */
void logKick(const QString& f_moderator, const QString& f_targetIPID, const QString& f_targetName, const QString f_targetOOCName); void logKick(const QString& f_moderator, const QString& f_targetIPID, const QString& f_reason);
/** /**
* @brief Signal connected to universal logger. Sends ban information to the logger. * @brief Signal connected to universal logger. Sends ban information to the logger.
*/ */
void logBan(const QString& f_moderator, const QString& f_targetIPID, const QString& f_targetName, const QString f_targetOOCName, void logBan(const QString& f_moderator, const QString& f_targetIPID, const QString &f_duration, const QString& f_reason);
const QString &f_duration);
/** /**
* @brief Signal connected to universal logger. Sends modcall information to the logger, triggering a write of the buffer * @brief Signal connected to universal logger. Sends modcall information to the logger, triggering a write of the buffer

View File

@ -74,13 +74,12 @@ public slots:
/** /**
* @brief Adds a player kick to the area buffer and writes it to the respective log format. * @brief Adds a player kick to the area buffer and writes it to the respective log format.
*/ */
void logKick(const QString& f_moderator, const QString& f_targetIPID, const QString& f_targetName, const QString f_targetOOCName); void logKick(const QString& f_moderator, const QString& f_targetIPID);
/** /**
* @brief Adds a player ban to the area buffer and writes it to the respective log format. * @brief Adds a player ban to the area buffer and writes it to the respective log format.
*/ */
void logBan(const QString& f_moderator, const QString& f_targetIPID, const QString& f_targetName, const QString f_targetOOCName, void logBan(const QString& f_moderator, const QString& f_targetIPID, const QString &f_duration);
const QString &f_duration);
/** /**
* @brief Adds a modcall event to the area buffer, also triggers modcall writing. * @brief Adds a modcall event to the area buffer, also triggers modcall writing.

View File

@ -78,6 +78,7 @@ void AOClient::cmdBan(int argc, QStringList argv)
client->socket->close(); client->socket->close();
kick_counter++; kick_counter++;
emit logBan(ban.moderator,ban.ipid,ban_duration,ban.reason);
if (ConfigManager::discordBanWebhookEnabled()) if (ConfigManager::discordBanWebhookEnabled())
emit server->banWebhookRequest(ban.ipid, ban.moderator, ban_duration, ban.reason, ban_id); emit server->banWebhookRequest(ban.ipid, ban.moderator, ban_duration, ban.reason, ban_id);
} }
@ -111,8 +112,15 @@ void AOClient::cmdKick(int argc, QStringList argv)
kick_counter++; kick_counter++;
} }
if (kick_counter > 0) if (kick_counter > 0) {
if (ConfigManager::authType() == DataTypes::AuthType::ADVANCED){
emit logKick(moderator_name, target_ipid, reason);
}
else {
emit logKick("Moderator",target_ipid,reason);
}
sendServerMessage("Kicked " + QString::number(kick_counter) + " client(s) with ipid " + target_ipid + " for reason: " + reason); sendServerMessage("Kicked " + QString::number(kick_counter) + " client(s) with ipid " + target_ipid + " for reason: " + reason);
}
else else
sendServerMessage("User with ipid not found!"); sendServerMessage("User with ipid not found!");
} }

View File

@ -103,19 +103,19 @@ void ULogger::logCMD(const QString& f_charName,const QString& f_ipid, const QStr
updateAreaBuffer(f_areaName,l_logEntry); updateAreaBuffer(f_areaName,l_logEntry);
} }
void ULogger::logKick(const QString& f_moderator, const QString& f_targetIPID, const QString& f_targetName, const QString f_targetOOCName) void ULogger::logKick(const QString& f_moderator, const QString& f_targetIPID)
{ {
QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss"); QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss");
QString l_logEntry = QStringLiteral("[%1][KICK][%2][%3][%4(%5)]") QString l_logEntry = QStringLiteral("[%1][%2][KICK][%3]")
.arg(l_time, f_moderator, f_targetIPID, f_targetName, f_targetOOCName); .arg(l_time, f_moderator, f_targetIPID);
updateAreaBuffer("SERVER",l_logEntry); updateAreaBuffer("SERVER",l_logEntry);
} }
void ULogger::logBan(const QString &f_moderator, const QString &f_targetIPID, const QString &f_targetName, const QString f_targetOOCName, const QString &f_duration) void ULogger::logBan(const QString &f_moderator, const QString &f_targetIPID, const QString &f_duration)
{ {
QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss"); QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss");
QString l_logEntry = QStringLiteral("[%1][BAN][%2][%3(%4)][%5][%6]") QString l_logEntry = QStringLiteral("[%1][%2][BAN][%3][%4]")
.arg(l_time, f_moderator, f_targetName, f_targetOOCName, f_targetIPID, f_duration); .arg(l_time, f_moderator, f_targetIPID, f_duration);
updateAreaBuffer("SERVER",l_logEntry); updateAreaBuffer("SERVER",l_logEntry);
} }

View File

@ -218,6 +218,7 @@ void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket pa
area->log(current_char, ipid, validated_packet); area->log(current_char, ipid, validated_packet);
server->broadcast(validated_packet, current_area); server->broadcast(validated_packet, current_area);
emit logIC((current_char + " " + showname), ooc_name,ipid,server->areas[current_area]->name(),last_message);
area->updateLastICMessage(validated_packet.contents); area->updateLastICMessage(validated_packet.contents);
server->can_send_ic_messages = false; server->can_send_ic_messages = false;
@ -265,12 +266,14 @@ void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket p
handleCommand(command, cmd_argc, cmd_argv); handleCommand(command, cmd_argc, cmd_argv);
area->logCmd(current_char, ipid, command, cmd_argv); area->logCmd(current_char, ipid, command, cmd_argv);
emit logCMD((current_char + " " + showname),ipid, ooc_name,command,cmd_argv,server->areas[current_area]->name());
return; return;
} }
else { else {
server->broadcast(final_packet, current_area); server->broadcast(final_packet, current_area);
} }
area->log(current_char, ipid, final_packet); area->log(current_char, ipid, final_packet);
emit logOOC((current_char + " " + showname), ooc_name, ipid,server->areas[current_area]->name(),message);
} }
void AOClient::pktPing(AreaData* area, int argc, QStringList argv, AOPacket packet) void AOClient::pktPing(AreaData* area, int argc, QStringList argv, AOPacket packet)
@ -420,6 +423,7 @@ void AOClient::pktModCall(AreaData* area, int argc, QStringList argv, AOPacket p
client->sendPacket(packet); client->sendPacket(packet);
} }
area->log(current_char, ipid, packet); area->log(current_char, ipid, packet);
emit logModcall((current_char + " " + showname),ipid, ooc_name, server->areas[current_area]->name());
if (ConfigManager::discordModcallWebhookEnabled()) { if (ConfigManager::discordModcallWebhookEnabled()) {
QString name = ooc_name; QString name = ooc_name;