diff --git a/.gitignore b/.gitignore index 71f4eee..3a767a6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ release/* *.Debug *.Release Makefile -ui_* \ No newline at end of file +ui_* +bin/* \ No newline at end of file diff --git a/.qmake.conf b/.qmake.conf new file mode 100644 index 0000000..c5384d3 --- /dev/null +++ b/.qmake.conf @@ -0,0 +1 @@ +top_srcdir=$$PWD/bin \ No newline at end of file diff --git a/SparrowBot.pro b/SparrowBot.pro index fe921d4..a8d5245 100644 --- a/SparrowBot.pro +++ b/SparrowBot.pro @@ -1,5 +1,7 @@ QT += core gui network widgets +BIN = bin + TEMPLATE = subdirs CONFIG += ordered c++11 SUBDIRS = ircbot \ diff --git a/app/app.pro b/app/app.pro index 5782f1d..de63268 100644 --- a/app/app.pro +++ b/app/app.pro @@ -1,12 +1,12 @@ QT += core gui network widgets -TARGET = ../../SparrowBot +DESTDIR = $$top_srcdir + +TARGET = SparrowBot TEMPLATE = app CONFIG += c++11 -debug:LIBS += ../ircbot/debug/libircbot.a -release:LIBS += ../ircbot/release/libircbot.a - +LIBS += $$top_srcdir/libircbot.a INCLUDEPATH += ../ircbot SOURCES = main.cpp \ diff --git a/app/main.cpp b/app/main.cpp index f33516a..69e5265 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -5,10 +5,10 @@ #include "regismodule.h" #include "sparrowmodule.h" -class CustomModule : public Module +class HelloWorldModule : public Module { public : - CustomModule() : Module() {} + HelloWorldModule() : Module() {} virtual bool messageHandler(Message msg) { @@ -29,8 +29,8 @@ public : int main(int argc, char *argv[]) { BotApp app = BotApp(argc, argv); - app.addModule(new CustomModule()); + //app.addModule(new HelloWorldModule()); app.addModule(new RegisModule()); - app.addModule(new SparrowModule()); + //app.addModule(new SparrowModule()); return app.exec(); } diff --git a/app/regismodule.cpp b/app/regismodule.cpp index 7d94900..65b6a07 100644 --- a/app/regismodule.cpp +++ b/app/regismodule.cpp @@ -2,7 +2,7 @@ #include "message.h" #include -RegisModule::RegisModule() +RegisModule::RegisModule() : regisEnable(false) { std::srand(time(NULL)); noms.push_back("Le chat"); @@ -35,7 +35,7 @@ RegisModule::RegisModule() bool RegisModule::messageHandler(Message msg) { - if(msg.args.contains("régis")) + if(msg.args.contains("régis ?")) { int nom1 = std::rand() % noms.size(); int nom2 = std::rand() % noms.size(); @@ -44,6 +44,14 @@ bool RegisModule::messageHandler(Message msg) answer = say(noms[nom1] + " " + adjectifs[adjectif] + " " + verbes[verbe] + " " + noms[nom2] + "."); return true; } + else if(msg.args.compare("!initrégis") == 0) + { + regisEnable = true; + setNick("il_est_con_Regis"); + answer = QString("NICK %1\r\n").arg(getNick()); + return true; + } + return false; } diff --git a/app/regismodule.h b/app/regismodule.h index ee74ca6..1f78655 100644 --- a/app/regismodule.h +++ b/app/regismodule.h @@ -7,6 +7,7 @@ class RegisModule : public Module { + bool regisEnable; std::vector noms; std::vector verbes; std::vector adjectifs; diff --git a/ircbot/botapp.cpp b/ircbot/botapp.cpp index c145a1e..3d5df3f 100644 --- a/ircbot/botapp.cpp +++ b/ircbot/botapp.cpp @@ -3,13 +3,13 @@ #include "ircbot.h" #include "socketirc.h" -BotApp::BotApp(int argc, char** argv) : - nogui(false), - server("irc.freenode.net"), - port(6667), - nick("SparrowBotDebug"), - chan("epicsparrow") +BotApp::BotApp(int argc, char** argv) : nogui(false) { + QString server = QString("irc.freenode.net"); + int port = 6667; + QString nick = QString("SparrowBotDebug"); + QString chan = QString("epicsparrow"); + // parsing arguments for(int i=1; i