fixed some things

This commit is contained in:
unknown 2015-06-05 16:37:36 +02:00
parent eb33a5f1f8
commit 47ff21f565
4 changed files with 15 additions and 9 deletions

View File

@ -1,12 +1,12 @@
QT += core gui network widgets
DESTDIR = $$relative_path($$bin_dir)
DESTDIR = $$bin_dir
TARGET = SparrowBot
TEMPLATE = app
CONFIG += c++11
LIBS += $$relative_path($$lib_dir/libircbot.a)
LIBS += $$lib_dir/libircbot.a
INCLUDEPATH += ../ircbot
SOURCES = main.cpp \

View File

@ -1,11 +1,11 @@
#include "regismodule.h"
#include "message.h"
RegisModule::RegisModule() : voc("../res/vocab.txt"), regisEnable(true) {}
RegisModule::RegisModule() : regisEnable(false) {}
bool RegisModule::messageHandler(Message msg)
{
if(msg.args.contains("régis ?"))
if(msg.args.contains("régis ?") && regisEnable)
{
answer = say(voc.getRandNom() + " "
+ voc.getRandAdjectif() + " "
@ -13,13 +13,14 @@ bool RegisModule::messageHandler(Message msg)
+ voc.getRandNom() + ".");
return true;
}
/*else if(msg.args.compare("!initrégis") == 0)
else if(msg.args.compare("!initrégis") == 0)
{
regisEnable = true;
voc.load("../res/vocab.txt");
setNick("il_est_con_Regis");
answer = QString("NICK %1\r\n").arg(getNick());
return true;
}*/
}
return false;
}

View File

@ -2,6 +2,7 @@
#include <time.h>
#include <QFile>
#include <QTextStream>
#include <iostream>
Vocab::Vocab()
{
@ -17,8 +18,12 @@ Vocab::Vocab(QString filename)
void Vocab::load(QString filename)
{
QFile file(filename);
if(file.open(QIODevice::ReadOnly | QIODevice::Text))
if(!file.exists())
std::cerr << "can't find " << filename << std::endl;
else if(file.open(QIODevice::ReadOnly | QIODevice::Text))
{
std::cerr << "file is open" << std::endl;
QTextStream stream(&file);
stream.setCodec("UTF-8");
@ -28,8 +33,8 @@ void Vocab::load(QString filename)
{
if(line.length() > 2)
{
line.remove(0, 2);
int firstChar = line.at(0).unicode();
line.remove(0, 2);
switch(firstChar)
{
case 'n' :

View File

@ -1,6 +1,6 @@
QT += core gui network widgets
DESTDIR = $$relative_path($$lib_dir)
DESTDIR = $$lib_dir
TARGET = ircbot