send warn and kick commands from chatcleaner to server
This commit is contained in:
@@ -122,7 +122,7 @@ bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) {
|
|||||||
netAck->serverVersion = CLEANER_PROTOCOL_VERSION;
|
netAck->serverVersion = CLEANER_PROTOCOL_VERSION;
|
||||||
string tmpServerSecret(serverSecret.toStdString());
|
string tmpServerSecret(serverSecret.toStdString());
|
||||||
OCTET_STRING_fromBuf(&netAck->serverSecret,
|
OCTET_STRING_fromBuf(&netAck->serverSecret,
|
||||||
tmpServerSecret.c_str(),
|
tmpServerSecret.c_str(),
|
||||||
tmpServerSecret.length());
|
tmpServerSecret.length());
|
||||||
sendMessageToClient(tmpAck);
|
sendMessageToClient(tmpAck);
|
||||||
}
|
}
|
||||||
@@ -141,20 +141,25 @@ bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) {
|
|||||||
string((const char *)netRequest->playerName.buf, netRequest->playerName.size).c_str()));
|
string((const char *)netRequest->playerName.buf, netRequest->playerName.size).c_str()));
|
||||||
QString message(QString::fromUtf8(
|
QString message(QString::fromUtf8(
|
||||||
string((const char *)netRequest->chatMessage.buf, netRequest->chatMessage.size).c_str()));
|
string((const char *)netRequest->chatMessage.buf, netRequest->chatMessage.size).c_str()));
|
||||||
QString checkMessage = myMessageFilter->check(playerId, nick, message);
|
QStringList checkreturn = myMessageFilter->check(playerId, nick, message);
|
||||||
|
QString checkAction = checkreturn.at(0);
|
||||||
|
QString checkMessage = checkreturn.at(1);
|
||||||
|
|
||||||
if (!checkMessage.isEmpty())
|
if (!checkAction.isEmpty())
|
||||||
{
|
{
|
||||||
InternalChatCleanerPacket tmpReply;
|
InternalChatCleanerPacket tmpReply;
|
||||||
tmpReply.GetMsg()->present = ChatCleanerMessage_PR_cleanerChatReplyMessage;
|
tmpReply.GetMsg()->present = ChatCleanerMessage_PR_cleanerChatReplyMessage;
|
||||||
CleanerChatReplyMessage_t *netReply = &tmpReply.GetMsg()->choice.cleanerChatReplyMessage;
|
CleanerChatReplyMessage_t *netReply = &tmpReply.GetMsg()->choice.cleanerChatReplyMessage;
|
||||||
netReply->requestId = netRequest->requestId;
|
netReply->requestId = netRequest->requestId;
|
||||||
netReply->playerId = netRequest->playerId;
|
netReply->playerId = netRequest->playerId;
|
||||||
netReply->cleanerActionType = cleanerActionType_cleanerActionNone;
|
|
||||||
/* cleanerActionType_cleanerActionNone
|
if(checkAction == "warn") {
|
||||||
cleanerActionType_cleanerActionWarning
|
netReply->cleanerActionType = cleanerActionType_cleanerActionWarning;
|
||||||
cleanerActionType_cleanerActionKick
|
}
|
||||||
cleanerActionType_cleanerActionBan */
|
else if(checkAction == "kick") {
|
||||||
|
netReply->cleanerActionType = cleanerActionType_cleanerActionKick;
|
||||||
|
}
|
||||||
|
/* cleanerActionType_cleanerActionBan */
|
||||||
string tmpCheck(checkMessage.toUtf8());
|
string tmpCheck(checkMessage.toUtf8());
|
||||||
netReply->cleanerText =
|
netReply->cleanerText =
|
||||||
OCTET_STRING_new_fromBuf(
|
OCTET_STRING_new_fromBuf(
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
#include "messagefilter.h"
|
#include "messagefilter.h"
|
||||||
|
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
@@ -40,9 +41,11 @@ MessageFilter::~MessageFilter() {
|
|||||||
delete myUrlCheck;
|
delete myUrlCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MessageFilter::check(unsigned playerId, QString nick, QString msg)
|
QStringList MessageFilter::check(unsigned playerId, QString nick, QString msg)
|
||||||
{
|
{
|
||||||
|
QStringList returnList;
|
||||||
QString returnMessage;
|
QString returnMessage;
|
||||||
|
QString returnAction;
|
||||||
|
|
||||||
OffenceType offence = NONE;
|
OffenceType offence = NONE;
|
||||||
ActionType action = NOTHING;
|
ActionType action = NOTHING;
|
||||||
@@ -85,11 +88,12 @@ QString MessageFilter::check(unsigned playerId, QString nick, QString msg)
|
|||||||
|
|
||||||
if(action == KICK) {
|
if(action == KICK) {
|
||||||
returnMessage = QString("Kick: %1\n").arg(nick);
|
returnMessage = QString("Kick: %1\n").arg(nick);
|
||||||
|
returnAction = QString("kick");
|
||||||
}
|
}
|
||||||
if(action == WARN) {
|
if(action == WARN) {
|
||||||
|
|
||||||
switch(offence) {
|
switch(offence) {
|
||||||
case BAD_WORD: {
|
case BAD_WORD: {
|
||||||
returnMessage = QString ("%1: Warning! No racial, religious, or sexually inflammatory language!\n").arg(nick);
|
returnMessage = QString ("%1: Warning! No racial, religious, or sexually inflammatory language!\n").arg(nick);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -111,12 +115,16 @@ QString MessageFilter::check(unsigned playerId, QString nick, QString msg)
|
|||||||
break;
|
break;
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
|
returnAction = QString("warn");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
returnAction = QString("");
|
||||||
returnMessage = QString("");
|
returnMessage = QString("");
|
||||||
}
|
}
|
||||||
return returnMessage;
|
|
||||||
|
returnList << returnAction << returnMessage;
|
||||||
|
return returnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageFilter::refreshConfig() {
|
void MessageFilter::refreshConfig() {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public:
|
|||||||
MessageFilter(CleanerConfig*);
|
MessageFilter(CleanerConfig*);
|
||||||
~MessageFilter();
|
~MessageFilter();
|
||||||
|
|
||||||
QString check(unsigned, QString, QString);
|
QStringList check(unsigned, QString, QString);
|
||||||
void refreshConfig();
|
void refreshConfig();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user