diff --git a/app/poilaumodule.cpp b/app/poilaumodule.cpp index ba01af8..ef740d4 100644 --- a/app/poilaumodule.cpp +++ b/app/poilaumodule.cpp @@ -2,14 +2,34 @@ #include "message.h" #include #include +#include "user.h" #define VOY_NONE -1 enum{VOY_A, VOY_E, VOY_I, VOY_O, VOY_U, VOY_ET, VOY_AI, VOY_OU, VOY_IN, VOY_ON, VOY_OI, VOY_EN, VOY_OUILLE, VOY_ATTE, VOY_US}; bool PoilAuModule::messageHandler(Message msg) { + if(msg.args.startsWith("!curse ") == 0 && getUsers()->getFromNick(msg.nick)->isOp()) + { + QStringList str = msg.args.split(' '); + if(str.size() == 2) + { + setCursed(str[1]); + answer = say(QString("%1 is now the cursed").arg(str[1])); + return true; + } + } + + if(msg.command.compare("NICK", Qt::CaseInsensitive) == 0 && msg.nick.compare(cursedNick) == 0) + { + setCursed(msg.args); + answer = say(QString("%1 is now the cursed").arg(msg.args)); + return true; + } + if (msg.args.startsWith("!")) return false; - if(!isReady) + bool cursed = (cursedNick.compare(msg.nick) == 0); + if(!isReady && !cursed) return false; if(msg.command.compare(QString("PRIVMSG"), Qt::CaseInsensitive) != 0) return false; @@ -173,6 +193,10 @@ void PoilAuModule::setReady() isReady = true; } +void PoilAuModule::setCursed(QString nick) +{ + cursedNick = nick; +} diff --git a/app/poilaumodule.h b/app/poilaumodule.h index 8623654..0d15b53 100644 --- a/app/poilaumodule.h +++ b/app/poilaumodule.h @@ -9,14 +9,16 @@ class PoilAuModule : public QObject, public Module Q_OBJECT bool isReady; + QString cursedNick; public: - PoilAuModule() : isReady(true) {} + PoilAuModule() : isReady(true), cursedNick("CaptainPlop") {} virtual bool messageHandler(Message msg); virtual QString getName(); public slots: void setReady(); + void setCursed(QString); }; #endif // POILAUMODULE_H diff --git a/app/punishermodule.cpp b/app/punishermodule.cpp index 67d1494..3e191db 100644 --- a/app/punishermodule.cpp +++ b/app/punishermodule.cpp @@ -69,6 +69,9 @@ bool PunisherModule::messageHandler(Message msg) return true; } + if(msg.nick.compare("LadySparrow") == 0) + return false; + for(const QString &w : forbidden_words) { if(msg.args.contains(w, Qt::CaseInsensitive))