send warn and kick commands from chatcleaner to server

This commit is contained in:
doitux
2010-07-13 08:21:00 +00:00
parent bd01ffad9f
commit a70ae9ddfb
3 changed files with 25 additions and 12 deletions
+13 -8
View File
@@ -122,7 +122,7 @@ bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) {
netAck->serverVersion = CLEANER_PROTOCOL_VERSION;
string tmpServerSecret(serverSecret.toStdString());
OCTET_STRING_fromBuf(&netAck->serverSecret,
tmpServerSecret.c_str(),
tmpServerSecret.c_str(),
tmpServerSecret.length());
sendMessageToClient(tmpAck);
}
@@ -141,20 +141,25 @@ bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) {
string((const char *)netRequest->playerName.buf, netRequest->playerName.size).c_str()));
QString message(QString::fromUtf8(
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;
tmpReply.GetMsg()->present = ChatCleanerMessage_PR_cleanerChatReplyMessage;
CleanerChatReplyMessage_t *netReply = &tmpReply.GetMsg()->choice.cleanerChatReplyMessage;
netReply->requestId = netRequest->requestId;
netReply->playerId = netRequest->playerId;
netReply->cleanerActionType = cleanerActionType_cleanerActionNone;
/* cleanerActionType_cleanerActionNone
cleanerActionType_cleanerActionWarning
cleanerActionType_cleanerActionKick
cleanerActionType_cleanerActionBan */
if(checkAction == "warn") {
netReply->cleanerActionType = cleanerActionType_cleanerActionWarning;
}
else if(checkAction == "kick") {
netReply->cleanerActionType = cleanerActionType_cleanerActionKick;
}
/* cleanerActionType_cleanerActionBan */
string tmpCheck(checkMessage.toUtf8());
netReply->cleanerText =
OCTET_STRING_new_fromBuf(
+11 -3
View File
@@ -1,3 +1,4 @@
#include "messagefilter.h"
#include <QtCore>
@@ -40,9 +41,11 @@ MessageFilter::~MessageFilter() {
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 returnAction;
OffenceType offence = NONE;
ActionType action = NOTHING;
@@ -85,11 +88,12 @@ QString MessageFilter::check(unsigned playerId, QString nick, QString msg)
if(action == KICK) {
returnMessage = QString("Kick: %1\n").arg(nick);
returnAction = QString("kick");
}
if(action == WARN) {
switch(offence) {
case BAD_WORD: {
case BAD_WORD: {
returnMessage = QString ("%1: Warning! No racial, religious, or sexually inflammatory language!\n").arg(nick);
}
break;
@@ -111,12 +115,16 @@ QString MessageFilter::check(unsigned playerId, QString nick, QString msg)
break;
default:;
}
returnAction = QString("warn");
}
}
else {
returnAction = QString("");
returnMessage = QString("");
}
return returnMessage;
returnList << returnAction << returnMessage;
return returnList;
}
void MessageFilter::refreshConfig() {
+1 -1
View File
@@ -17,7 +17,7 @@ public:
MessageFilter(CleanerConfig*);
~MessageFilter();
QString check(unsigned, QString, QString);
QStringList check(unsigned, QString, QString);
void refreshConfig();
private: