added funny module

This commit is contained in:
Anselme 2015-08-18 13:30:12 +02:00
parent 58d369b018
commit 3a923dd675
7 changed files with 114 additions and 5 deletions

View File

@ -12,9 +12,11 @@ INCLUDEPATH += ../ircbot
SOURCES = main.cpp \
regismodule.cpp \
sparrowmodule.cpp \
vocab.cpp
vocab.cpp \
poilaumodule.cpp
HEADERS += \
regismodule.h \
sparrowmodule.h \
vocab.h
vocab.h \
poilaumodule.h

View File

@ -4,6 +4,7 @@
#include "basemodule.h"
#include "regismodule.h"
#include "sparrowmodule.h"
#include "poilaumodule.h"
class HelloWorldModule : public Module
{
@ -32,5 +33,6 @@ int main(int argc, char *argv[])
app.addModule(new HelloWorldModule());
app.addModule(new RegisModule());
app.addModule(new SparrowModule());
app.addModule(new PoilAuModule());
return app.exec();
}

93
app/poilaumodule.cpp Normal file
View File

@ -0,0 +1,93 @@
#include "poilaumodule.h"
#include "message.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_EN, VOY_OUILLE};
bool PoilAuModule::messageHandler(Message msg)
{
int voy = VOY_NONE;
if(msg.args.endsWith("eu", Qt::CaseInsensitive))
voy = VOY_E;
else if(msg.args.endsWith("au", Qt::CaseInsensitive))
voy = VOY_O;
else if(msg.args.endsWith("ou", Qt::CaseInsensitive))
voy = VOY_OU;
else if(msg.args.endsWith("u", Qt::CaseInsensitive))
voy = VOY_U;
if(msg.args.endsWith("oo", Qt::CaseInsensitive))
voy = VOY_OU;
else if(msg.args.endsWith("o", Qt::CaseInsensitive))
voy = VOY_O;
if(msg.args.endsWith("et", Qt::CaseInsensitive))
voy = VOY_ET;
if(msg.args.endsWith("é", Qt::CaseInsensitive))
voy = VOY_ET;
if(msg.args.endsWith("er", Qt::CaseInsensitive))
voy = VOY_ET;
if(msg.args.endsWith("è", Qt::CaseInsensitive))
voy = VOY_AI;
if(msg.args.endsWith("ai", Qt::CaseInsensitive))
voy = VOY_AI;
if(msg.args.endsWith("an", Qt::CaseInsensitive))
voy = VOY_EN;
if(msg.args.endsWith("en", Qt::CaseInsensitive))
voy = VOY_EN;
if(msg.args.endsWith("in", Qt::CaseInsensitive))
voy = VOY_IN;
if(msg.args.endsWith("a", Qt::CaseInsensitive))
voy = VOY_A;
if(msg.args.endsWith("i", Qt::CaseInsensitive))
voy = VOY_I;
if(msg.args.endsWith("ouille", Qt::CaseInsensitive))
voy = VOY_OUILLE;
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_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_EN :
answer = say("Poil aux dents.");
break;
case VOY_OUILLE :
answer = say("Poil aux couilles.");
break;
}
return true;
}
QString PoilAuModule::getName()
{
return "poilau";
}

13
app/poilaumodule.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef POILAUMODULE_H
#define POILAUMODULE_H
#include "module.h"
class PoilAuModule : public Module
{
public:
virtual bool messageHandler(Message msg);
virtual QString getName();
};
#endif // POILAUMODULE_H

View File

@ -3,7 +3,6 @@
#include <QString>
class Message
{
public:

View File

@ -1,6 +1,6 @@
#include "prompt.h"
Prompt::setChan(const QString& myChan)
void Prompt::setChan(const QString& myChan)
{
chan = myChan;
}

View File

@ -11,7 +11,7 @@ class Prompt : public QLineEdit
public:
Prompt(QWidget*& w) : QLineEdit(w), chan("epicsparrow") {}
setChan(const QString& myChan);
void setChan(const QString& myChan);
public slots:
void advancedConfirmationPerformed();