#include "poilaumodule.h" #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; bool cursed = (cursedNick.compare(msg.nick) == 0); if(!isReady && !cursed) return false; if(msg.command.compare(QString("PRIVMSG"), Qt::CaseInsensitive) != 0) return false; int voy = VOY_NONE; QString truncated = msg.args; if(truncated.endsWith("+", Qt::CaseInsensitive)) { voy = VOY_US; } else { while(true) { if(truncated.size() == 1 || truncated.at(truncated.size()-1).isNumber()) return false; if(truncated.at(truncated.size()-1).isLetter() && truncated.at(truncated.size()-2).isLetter()) break; truncated.chop(1); } } if(truncated.endsWith("eu", Qt::CaseInsensitive)) voy = VOY_E; else if(truncated.endsWith("eux", Qt::CaseInsensitive)) voy = VOY_E; else if(truncated.endsWith("au", Qt::CaseInsensitive)) voy = VOY_O; else if(truncated.endsWith("ou", Qt::CaseInsensitive)) voy = VOY_OU; else if(truncated.endsWith("où", Qt::CaseInsensitive)) voy = VOY_OU; else if(truncated.endsWith("u", Qt::CaseInsensitive)) voy = VOY_U; if(truncated.endsWith("oo", Qt::CaseInsensitive)) voy = VOY_OU; else if(truncated.endsWith("o", Qt::CaseInsensitive)) voy = VOY_O; if(truncated.endsWith("ait", Qt::CaseInsensitive)) voy = VOY_AI; if(truncated.endsWith("ais", Qt::CaseInsensitive)) voy = VOY_AI; if(truncated.endsWith("ai", Qt::CaseInsensitive)) voy = VOY_AI; else if(truncated.endsWith("oi", Qt::CaseInsensitive)) voy = VOY_OI; else if(truncated.endsWith("i", Qt::CaseInsensitive)) voy = VOY_I; if(truncated.endsWith("et", Qt::CaseInsensitive)) voy = VOY_ET; if(truncated.endsWith("é", Qt::CaseInsensitive)) voy = VOY_ET; if(truncated.endsWith("er", Qt::CaseInsensitive)) voy = VOY_ET; if(truncated.endsWith("è", Qt::CaseInsensitive)) voy = VOY_AI; if(truncated.endsWith("an", Qt::CaseInsensitive)) voy = VOY_EN; if(truncated.endsWith("en", Qt::CaseInsensitive)) voy = VOY_EN; if(truncated.endsWith("ment", Qt::CaseInsensitive)) voy = VOY_EN; if(truncated.endsWith("in", Qt::CaseInsensitive)) voy = VOY_IN; if(truncated.endsWith("on", Qt::CaseInsensitive)) voy = VOY_ON; if(truncated.endsWith("ont", Qt::CaseInsensitive)) voy = VOY_ON; if(truncated.endsWith("oie", Qt::CaseInsensitive)) voy = VOY_OI; if(truncated.endsWith("ois", Qt::CaseInsensitive)) voy = VOY_OI; if(truncated.endsWith("oit", Qt::CaseInsensitive)) voy = VOY_OI; if(truncated.endsWith("a", Qt::CaseInsensitive)) voy = VOY_A; if(truncated.endsWith("à", Qt::CaseInsensitive)) voy = VOY_A; if(truncated.endsWith("ouille", Qt::CaseInsensitive)) voy = VOY_OUILLE; if(truncated.endsWith("atte", Qt::CaseInsensitive)) voy = VOY_ATTE; if(truncated.endsWith("us", Qt::CaseInsensitive)) voy = VOY_US; if(voy == VOY_NONE) return false; switch(voy) { case VOY_A : answer = say("Poil au bras."); break; case VOY_E : answer = say("Poil aux cheveux."); break; case VOY_I : answer = say("Poil à la vessie."); break; case VOY_O : answer = say("Poil au dos."); break; case VOY_U : answer = say("Poil au cul."); break; case VOY_US : answer = say("Poil à l'anus."); break; case VOY_ET : answer = say("Poil au nez."); break; case VOY_AI : answer = say("Poil au nez."); break; case VOY_OU : answer = say("Poil au cou."); break; case VOY_IN : answer = say("Poil aux mains."); break; case VOY_ON : answer = say("Poil au fion."); break; case VOY_OI : answer = say("Poil aux doigts."); break; case VOY_EN : answer = say("Poil aux dents."); break; case VOY_OUILLE : answer = say("Poil aux couilles."); break; case VOY_ATTE : answer = say("Poil à la chatte."); break; } isReady = false; std::srand(time(NULL)); int waitTime; if(std::rand()%2) waitTime = std::rand()%900000; // short (0 - 15 min) else waitTime = std::rand()%9000000; // long (15 min - 3 h) QTimer::singleShot(waitTime, (QObject*)this, SLOT(setReady())); return true; } QString PoilAuModule::getName() { return "poilau"; } void PoilAuModule::setReady() { isReady = true; } void PoilAuModule::setCursed(QString nick) { cursedNick = nick; }