From 3a923dd675686f46999aad6696f670d1e6e517ff Mon Sep 17 00:00:00 2001 From: Anselme Date: Tue, 18 Aug 2015 13:30:12 +0200 Subject: [PATCH] added funny module --- app/app.pro | 6 ++- app/main.cpp | 2 + app/poilaumodule.cpp | 93 ++++++++++++++++++++++++++++++++++++++++++++ app/poilaumodule.h | 13 +++++++ ircbot/message.h | 1 - ircbot/prompt.cpp | 2 +- ircbot/prompt.h | 2 +- 7 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 app/poilaumodule.cpp create mode 100644 app/poilaumodule.h diff --git a/app/app.pro b/app/app.pro index 6bc8b0c..57dc881 100644 --- a/app/app.pro +++ b/app/app.pro @@ -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 diff --git a/app/main.cpp b/app/main.cpp index 0fb0c0c..b202162 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -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(); } diff --git a/app/poilaumodule.cpp b/app/poilaumodule.cpp new file mode 100644 index 0000000..a760351 --- /dev/null +++ b/app/poilaumodule.cpp @@ -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"; +} diff --git a/app/poilaumodule.h b/app/poilaumodule.h new file mode 100644 index 0000000..37da97f --- /dev/null +++ b/app/poilaumodule.h @@ -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 diff --git a/ircbot/message.h b/ircbot/message.h index f165a03..422cd7d 100644 --- a/ircbot/message.h +++ b/ircbot/message.h @@ -3,7 +3,6 @@ #include - class Message { public: diff --git a/ircbot/prompt.cpp b/ircbot/prompt.cpp index 72b65a6..7429659 100644 --- a/ircbot/prompt.cpp +++ b/ircbot/prompt.cpp @@ -1,6 +1,6 @@ #include "prompt.h" -Prompt::setChan(const QString& myChan) +void Prompt::setChan(const QString& myChan) { chan = myChan; } diff --git a/ircbot/prompt.h b/ircbot/prompt.h index eb4d0e5..182bf5f 100644 --- a/ircbot/prompt.h +++ b/ircbot/prompt.h @@ -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();