fixed remove
This commit is contained in:
parent
70e0a150a7
commit
9a3052e9cb
@ -10,13 +10,39 @@ PunisherModule::PunisherModule()
|
|||||||
|
|
||||||
bool PunisherModule::messageHandler(Message msg)
|
bool PunisherModule::messageHandler(Message msg)
|
||||||
{
|
{
|
||||||
for(const QString &w : forbidden_words)
|
if(msg.args.startsWith("!forbidden remove ") && getUsers()->getFromNick(msg.nick)->isOp())
|
||||||
{
|
{
|
||||||
if(msg.args.contains(w, Qt::CaseInsensitive))
|
QStringList str = msg.args.split(' ');
|
||||||
|
int i=2;
|
||||||
|
answer = QString("");
|
||||||
|
for(; i<str.size(); ++i)
|
||||||
{
|
{
|
||||||
answer = QString("KICK #%1 %2\r\n").arg(getChan()).arg(msg.nick);
|
bool found = false;
|
||||||
|
for(auto it = forbidden_words.begin(); it != forbidden_words.end(); it++)
|
||||||
|
{
|
||||||
|
if(str[i].compare(*it, Qt::CaseInsensitive) == 0)
|
||||||
|
{
|
||||||
|
forbidden_words.erase(it);
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(found)
|
||||||
|
answer += say(QString("removed %1 to the list of forbidden words").arg(str[i]));
|
||||||
|
else
|
||||||
|
answer += say(QString("%1 was not part of the list of forbidden words").arg(str[i]));
|
||||||
|
|
||||||
|
}
|
||||||
|
if(i==2)
|
||||||
|
answer = say(QString("missing argument"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(msg.args.compare("!forbidden reset") == 0 && getUsers()->getFromNick(msg.nick)->isOp())
|
||||||
|
{
|
||||||
|
forbidden_words.clear();
|
||||||
|
answer = say(QString("removed all forbidden words"));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(msg.args.startsWith("!forbidden add ") && getUsers()->getFromNick(msg.nick)->isOp())
|
if(msg.args.startsWith("!forbidden add ") && getUsers()->getFromNick(msg.nick)->isOp())
|
||||||
@ -34,37 +60,6 @@ bool PunisherModule::messageHandler(Message msg)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(msg.args.startsWith("!forbidden remove ") && getUsers()->getFromNick(msg.nick)->isOp())
|
|
||||||
{
|
|
||||||
QStringList str = msg.args.split(' ');
|
|
||||||
int i=2;
|
|
||||||
answer = QString("");
|
|
||||||
for(; i<str.size(); ++i)
|
|
||||||
{
|
|
||||||
for(auto it = forbidden_words.begin(); it != forbidden_words.end(); it++)
|
|
||||||
{
|
|
||||||
if(str[i].compare(*it, Qt::CaseInsensitive) == 0)
|
|
||||||
{
|
|
||||||
forbidden_words.erase(it);
|
|
||||||
answer += say(QString("removed %1 to the list of forbidden words").arg(str[i]));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
answer += say(QString("%1 was not part of the list of forbidden words").arg(str[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if(i==2)
|
|
||||||
answer = say(QString("missing argument"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(msg.args.compare("!forbidden reset") == 0 && getUsers()->getFromNick(msg.nick)->isOp())
|
|
||||||
{
|
|
||||||
forbidden_words.clear();
|
|
||||||
answer = say(QString("removed all forbidden words"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(msg.args.compare("!forbidden list") == 0)
|
if(msg.args.compare("!forbidden list") == 0)
|
||||||
{
|
{
|
||||||
QString str = QString("Forbidden words are : ");
|
QString str = QString("Forbidden words are : ");
|
||||||
@ -74,6 +69,15 @@ bool PunisherModule::messageHandler(Message msg)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(const QString &w : forbidden_words)
|
||||||
|
{
|
||||||
|
if(msg.args.contains(w, Qt::CaseInsensitive))
|
||||||
|
{
|
||||||
|
answer = QString("KICK #%1 %2\r\n").arg(getChan()).arg(msg.nick);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user