plop
This commit is contained in:
parent
ee95c12417
commit
09c0ab5b56
@ -18,7 +18,8 @@ SOURCES += mainwindow.cpp \
|
||||
ircbot.cpp \
|
||||
botapp.cpp \
|
||||
module.cpp \
|
||||
basemodule.cpp
|
||||
basemodule.cpp \
|
||||
main.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
socketirc.h \
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define BASEMODULE_H
|
||||
|
||||
#include "module.h"
|
||||
#include "user.h"
|
||||
|
||||
class BaseModule : public Module
|
||||
{
|
||||
|
@ -1,4 +1,7 @@
|
||||
#include "botapp.h"
|
||||
#include "mainwindow.h"
|
||||
#include "ircbot.h"
|
||||
#include "socketirc.h"
|
||||
|
||||
BotApp::BotApp(int argc, char** argv) :
|
||||
nogui(false),
|
||||
@ -65,8 +68,7 @@ int BotApp::exec()
|
||||
return sock->connectToServer(coreApp);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
void BotApp::addModule(Module* module)
|
||||
{
|
||||
BotApp app = BotApp(argc, argv);
|
||||
return app.exec();
|
||||
bot->addModule(module);
|
||||
}
|
||||
|
13
botapp.h
13
botapp.h
@ -1,13 +1,17 @@
|
||||
#ifndef BOTAPP_H
|
||||
#define BOTAPP_H
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "socketirc.h"
|
||||
#include "ircbot.h"
|
||||
#include <QApplication>
|
||||
|
||||
class BotApp
|
||||
class Module;
|
||||
class IRCBot;
|
||||
class SocketIRC;
|
||||
class MainWindow;
|
||||
|
||||
class BotApp : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
bool nogui = false;
|
||||
QString server = "irc.freenode.net";
|
||||
int port = 6667;
|
||||
@ -21,6 +25,7 @@ class BotApp
|
||||
|
||||
public:
|
||||
BotApp(int argc, char** argv);
|
||||
void addModule(Module* module);
|
||||
~BotApp();
|
||||
int exec();
|
||||
};
|
||||
|
@ -1,9 +1,6 @@
|
||||
#include "ircbot.h"
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <QStringList>
|
||||
|
||||
using namespace std;
|
||||
#include "basemodule.h"
|
||||
#include "message.h"
|
||||
|
||||
IRCBot::IRCBot(QString nick_, QString chan_) : nick(nick_), chan(chan_)
|
||||
{
|
||||
|
10
ircbot.h
10
ircbot.h
@ -1,12 +1,12 @@
|
||||
#ifndef IRCBOT_H
|
||||
#define IRCBOT_H
|
||||
|
||||
#include "user.h"
|
||||
#include "message.h"
|
||||
#include <QObject>
|
||||
#include <vector>
|
||||
#include "module.h"
|
||||
#include "basemodule.h"
|
||||
|
||||
|
||||
class Module;
|
||||
class BaseModule;
|
||||
|
||||
class IRCBot : public QObject
|
||||
{
|
||||
@ -20,7 +20,7 @@ class IRCBot : public QObject
|
||||
public:
|
||||
IRCBot(QString nick_, QString chan_);
|
||||
|
||||
protected:
|
||||
public:
|
||||
void addModule(Module* module);
|
||||
|
||||
public slots:
|
||||
|
25
main.cpp
Normal file
25
main.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "botapp.h"
|
||||
#include "module.h"
|
||||
#include "message.h"
|
||||
|
||||
class CustomModule : public Module
|
||||
{
|
||||
CustomModule() : Module(), answer("coucou") {}
|
||||
|
||||
bool messageHandler(Message msg)
|
||||
{
|
||||
return msg.args.compare("plop ?") == 0;
|
||||
}
|
||||
|
||||
QString getName()
|
||||
{
|
||||
return "custom";
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
BotApp app = BotApp(argc, argv);
|
||||
app.addModule(new CustomModule());
|
||||
return app.exec();
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include "prompt.h"
|
||||
#include <QMainWindow>
|
||||
#include <QTextBrowser>
|
||||
#include <QSlider>
|
||||
#include <QProgressBar>
|
||||
|
||||
class Prompt;
|
||||
class QTextBrowser;
|
||||
class QSlider;
|
||||
class QProgressBar;
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
|
@ -1,9 +1,7 @@
|
||||
#include "message.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
#include <vector>
|
||||
|
||||
Message::Message(QString str)
|
||||
{
|
||||
|
@ -1,10 +1,8 @@
|
||||
#ifndef MESSAGE_H
|
||||
#define MESSAGE_H
|
||||
|
||||
#include <string>
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
#include "user.h"
|
||||
|
||||
|
||||
class Message
|
||||
{
|
||||
|
@ -15,22 +15,22 @@ void Module::setEnabled(bool newStatus)
|
||||
enabled = newStatus;
|
||||
}
|
||||
|
||||
QString getNick()
|
||||
QString Module::getNick()
|
||||
{
|
||||
return nick;
|
||||
}
|
||||
|
||||
QString getChan()
|
||||
QString Module::getChan()
|
||||
{
|
||||
return chan;
|
||||
}
|
||||
|
||||
void setNick(QString nick_)
|
||||
void Module::setNick(QString nick_)
|
||||
{
|
||||
nick = nick_;
|
||||
}
|
||||
|
||||
void setChan(QString chan_)
|
||||
void Module::setChan(QString chan_)
|
||||
{
|
||||
chan = chan_;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "socketirc.h"
|
||||
#include <iostream>
|
||||
#include <QCoreApplication>
|
||||
|
||||
SocketIRC::SocketIRC() : server("irc.freenode.net"), port(6667), isConnected(false)
|
||||
{
|
||||
|
@ -2,9 +2,8 @@
|
||||
#define SOCKETIRC_H
|
||||
|
||||
#include <QTcpSocket>
|
||||
#include <QPushButton>
|
||||
#include <QThread>
|
||||
#include <QCoreApplication>
|
||||
|
||||
class QCoreApplication;
|
||||
|
||||
class SocketIRC : public QObject
|
||||
{
|
||||
|
74
ui_mainwindow.h
Normal file
74
ui_mainwindow.h
Normal file
@ -0,0 +1,74 @@
|
||||
/********************************************************************************
|
||||
** Form generated from reading UI file 'mainwindow.ui'
|
||||
**
|
||||
** Created by: Qt User Interface Compiler version 5.4.1
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef UI_MAINWINDOW_H
|
||||
#define UI_MAINWINDOW_H
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtWidgets/QAction>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QButtonGroup>
|
||||
#include <QtWidgets/QGridLayout>
|
||||
#include <QtWidgets/QHeaderView>
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <QtWidgets/QTextBrowser>
|
||||
#include <QtWidgets/QWidget>
|
||||
#include "prompt.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class Ui_MainWindow
|
||||
{
|
||||
public:
|
||||
QWidget *centralWidget;
|
||||
QGridLayout *gridLayout;
|
||||
QTextBrowser *monitoringConsole;
|
||||
Prompt *prompt;
|
||||
|
||||
void setupUi(QMainWindow *MainWindow)
|
||||
{
|
||||
if (MainWindow->objectName().isEmpty())
|
||||
MainWindow->setObjectName(QStringLiteral("MainWindow"));
|
||||
MainWindow->resize(374, 404);
|
||||
centralWidget = new QWidget(MainWindow);
|
||||
centralWidget->setObjectName(QStringLiteral("centralWidget"));
|
||||
gridLayout = new QGridLayout(centralWidget);
|
||||
gridLayout->setSpacing(6);
|
||||
gridLayout->setContentsMargins(11, 11, 11, 11);
|
||||
gridLayout->setObjectName(QStringLiteral("gridLayout"));
|
||||
monitoringConsole = new QTextBrowser(centralWidget);
|
||||
monitoringConsole->setObjectName(QStringLiteral("monitoringConsole"));
|
||||
|
||||
gridLayout->addWidget(monitoringConsole, 1, 0, 1, 2);
|
||||
|
||||
prompt = new Prompt(centralWidget);
|
||||
prompt->setObjectName(QStringLiteral("prompt"));
|
||||
|
||||
gridLayout->addWidget(prompt, 0, 0, 1, 2);
|
||||
|
||||
MainWindow->setCentralWidget(centralWidget);
|
||||
|
||||
retranslateUi(MainWindow);
|
||||
|
||||
QMetaObject::connectSlotsByName(MainWindow);
|
||||
} // setupUi
|
||||
|
||||
void retranslateUi(QMainWindow *MainWindow)
|
||||
{
|
||||
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0));
|
||||
} // retranslateUi
|
||||
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow: public Ui_MainWindow {};
|
||||
} // namespace Ui
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // UI_MAINWINDOW_H
|
Loading…
x
Reference in New Issue
Block a user