added cooldown for poilau module, and added ponctuation ignoring at end of messages
This commit is contained in:
parent
4c1e0d0db0
commit
ac32f670ca
@ -1,73 +1,90 @@
|
|||||||
#include "poilaumodule.h"
|
#include "poilaumodule.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
#include <QTimer>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#define VOY_NONE -1
|
#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};
|
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};
|
||||||
|
|
||||||
bool PoilAuModule::messageHandler(Message msg)
|
bool PoilAuModule::messageHandler(Message msg)
|
||||||
{
|
{
|
||||||
|
if(!isReady)
|
||||||
|
return false;
|
||||||
if(msg.command.compare(QString("PRIVMSG"), Qt::CaseInsensitive) != 0)
|
if(msg.command.compare(QString("PRIVMSG"), Qt::CaseInsensitive) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int voy = VOY_NONE;
|
int voy = VOY_NONE;
|
||||||
|
QString truncated = msg.args;
|
||||||
|
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(msg.args.endsWith("eu", Qt::CaseInsensitive))
|
if(truncated.endsWith("eu", Qt::CaseInsensitive))
|
||||||
voy = VOY_E;
|
voy = VOY_E;
|
||||||
if(msg.args.endsWith("eux", Qt::CaseInsensitive))
|
if(truncated.endsWith("eux", Qt::CaseInsensitive))
|
||||||
voy = VOY_E;
|
voy = VOY_E;
|
||||||
else if(msg.args.endsWith("au", Qt::CaseInsensitive))
|
else if(truncated.endsWith("au", Qt::CaseInsensitive))
|
||||||
voy = VOY_O;
|
voy = VOY_O;
|
||||||
else if(msg.args.endsWith("ou", Qt::CaseInsensitive))
|
else if(truncated.endsWith("ou", Qt::CaseInsensitive))
|
||||||
voy = VOY_OU;
|
voy = VOY_OU;
|
||||||
else if(msg.args.endsWith("u", Qt::CaseInsensitive))
|
else if(truncated.endsWith("où", Qt::CaseInsensitive))
|
||||||
|
voy = VOY_OU;
|
||||||
|
else if(truncated.endsWith("u", Qt::CaseInsensitive))
|
||||||
voy = VOY_U;
|
voy = VOY_U;
|
||||||
|
|
||||||
if(msg.args.endsWith("oo", Qt::CaseInsensitive))
|
if(truncated.endsWith("oo", Qt::CaseInsensitive))
|
||||||
voy = VOY_OU;
|
voy = VOY_OU;
|
||||||
else if(msg.args.endsWith("o", Qt::CaseInsensitive))
|
else if(truncated.endsWith("o", Qt::CaseInsensitive))
|
||||||
voy = VOY_O;
|
voy = VOY_O;
|
||||||
|
|
||||||
if(msg.args.endsWith("ait", Qt::CaseInsensitive))
|
if(truncated.endsWith("ait", Qt::CaseInsensitive))
|
||||||
voy = VOY_AI;
|
voy = VOY_AI;
|
||||||
if(msg.args.endsWith("ais", Qt::CaseInsensitive))
|
if(truncated.endsWith("ais", Qt::CaseInsensitive))
|
||||||
voy = VOY_AI;
|
voy = VOY_AI;
|
||||||
if(msg.args.endsWith("ai", Qt::CaseInsensitive))
|
if(truncated.endsWith("ai", Qt::CaseInsensitive))
|
||||||
voy = VOY_AI;
|
voy = VOY_AI;
|
||||||
else if(msg.args.endsWith("oi", Qt::CaseInsensitive))
|
else if(truncated.endsWith("oi", Qt::CaseInsensitive))
|
||||||
voy = VOY_OI;
|
voy = VOY_OI;
|
||||||
else if(msg.args.endsWith("i", Qt::CaseInsensitive))
|
else if(truncated.endsWith("i", Qt::CaseInsensitive))
|
||||||
voy = VOY_I;
|
voy = VOY_I;
|
||||||
|
|
||||||
if(msg.args.endsWith("et", Qt::CaseInsensitive))
|
if(truncated.endsWith("et", Qt::CaseInsensitive))
|
||||||
voy = VOY_ET;
|
voy = VOY_ET;
|
||||||
if(msg.args.endsWith("é", Qt::CaseInsensitive))
|
if(truncated.endsWith("é", Qt::CaseInsensitive))
|
||||||
voy = VOY_ET;
|
voy = VOY_ET;
|
||||||
if(msg.args.endsWith("er", Qt::CaseInsensitive))
|
if(truncated.endsWith("er", Qt::CaseInsensitive))
|
||||||
voy = VOY_ET;
|
voy = VOY_ET;
|
||||||
if(msg.args.endsWith("è", Qt::CaseInsensitive))
|
if(truncated.endsWith("è", Qt::CaseInsensitive))
|
||||||
voy = VOY_AI;
|
voy = VOY_AI;
|
||||||
if(msg.args.endsWith("an", Qt::CaseInsensitive))
|
if(truncated.endsWith("an", Qt::CaseInsensitive))
|
||||||
voy = VOY_EN;
|
voy = VOY_EN;
|
||||||
if(msg.args.endsWith("en", Qt::CaseInsensitive))
|
if(truncated.endsWith("en", Qt::CaseInsensitive))
|
||||||
voy = VOY_EN;
|
voy = VOY_EN;
|
||||||
if(msg.args.endsWith("ment", Qt::CaseInsensitive))
|
if(truncated.endsWith("ment", Qt::CaseInsensitive))
|
||||||
voy = VOY_EN;
|
voy = VOY_EN;
|
||||||
if(msg.args.endsWith("in", Qt::CaseInsensitive))
|
if(truncated.endsWith("in", Qt::CaseInsensitive))
|
||||||
voy = VOY_IN;
|
voy = VOY_IN;
|
||||||
if(msg.args.endsWith("on", Qt::CaseInsensitive))
|
if(truncated.endsWith("on", Qt::CaseInsensitive))
|
||||||
voy = VOY_ON;
|
voy = VOY_ON;
|
||||||
if(msg.args.endsWith("ont", Qt::CaseInsensitive))
|
if(truncated.endsWith("ont", Qt::CaseInsensitive))
|
||||||
voy = VOY_ON;
|
voy = VOY_ON;
|
||||||
if(msg.args.endsWith("oie", Qt::CaseInsensitive))
|
if(truncated.endsWith("oie", Qt::CaseInsensitive))
|
||||||
voy = VOY_OI;
|
voy = VOY_OI;
|
||||||
if(msg.args.endsWith("ois", Qt::CaseInsensitive))
|
if(truncated.endsWith("ois", Qt::CaseInsensitive))
|
||||||
voy = VOY_OI;
|
voy = VOY_OI;
|
||||||
if(msg.args.endsWith("oit", Qt::CaseInsensitive))
|
if(truncated.endsWith("oit", Qt::CaseInsensitive))
|
||||||
voy = VOY_OI;
|
voy = VOY_OI;
|
||||||
if(msg.args.endsWith("a", Qt::CaseInsensitive))
|
if(truncated.endsWith("a", Qt::CaseInsensitive))
|
||||||
|
voy = VOY_A;
|
||||||
|
if(truncated.endsWith("à", Qt::CaseInsensitive))
|
||||||
voy = VOY_A;
|
voy = VOY_A;
|
||||||
|
|
||||||
if(msg.args.endsWith("ouille", Qt::CaseInsensitive))
|
if(truncated.endsWith("ouille", Qt::CaseInsensitive))
|
||||||
voy = VOY_OUILLE;
|
voy = VOY_OUILLE;
|
||||||
|
|
||||||
if(voy == VOY_NONE)
|
if(voy == VOY_NONE)
|
||||||
@ -115,6 +132,14 @@ bool PoilAuModule::messageHandler(Message msg)
|
|||||||
answer = say("Poil aux couilles.");
|
answer = say("Poil aux couilles.");
|
||||||
break;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,3 +147,13 @@ QString PoilAuModule::getName()
|
|||||||
{
|
{
|
||||||
return "poilau";
|
return "poilau";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PoilAuModule::setReady()
|
||||||
|
{
|
||||||
|
isReady = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,13 +1,22 @@
|
|||||||
#ifndef POILAUMODULE_H
|
#ifndef POILAUMODULE_H
|
||||||
#define POILAUMODULE_H
|
#define POILAUMODULE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
|
|
||||||
class PoilAuModule : public Module
|
class PoilAuModule : public QObject, public Module
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
bool isReady;
|
||||||
public:
|
public:
|
||||||
|
PoilAuModule() : isReady(true) {}
|
||||||
|
|
||||||
virtual bool messageHandler(Message msg);
|
virtual bool messageHandler(Message msg);
|
||||||
virtual QString getName();
|
virtual QString getName();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setReady();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // POILAUMODULE_H
|
#endif // POILAUMODULE_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user