123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #include "applicationdata.h"
- #include "ircclientstarter.h"
- #include "ircclient.h"
- #include "httpserver.h"
- #include "global.h"
- #include "version.h"
- #include <QThread>
- #include <QCoreApplication>
- #include <QDebug>
- int main(int argc, char *argv[])
- {
- if (argc < 2) {
- qInfo().noquote() << "No parameters passed. Use -h or --help for usage information.";
- return 1;
- }
- QCoreApplication a(argc, argv);
- QString configFile;
- for (int i = 1; i < argc; i++) {
- QString param(argv[i]);
- if ((param == "--example" or param == "-e") and i+1 < argc) {
- ApplicationData::createConfigExample (QString{argv[i+1]});
- return 0;
- }
- else if (param == "--help" or param == "-h") {
- qInfo().noquote() << "Usage: Pass the configuration file via --config and let's go!\n"
- "Possible arguments:\n"
- "-e --example <output file> - create example config file\n"
- "-c --config <input file> - path to configuration file\n"
- "-v --version - print version";
- return 0;
- }
- else if ((param == "--config" or param == "-c") and i+1 < argc) {
- configFile = QString{argv[i+1]};
- }
- else if ((param == "--version" or param == "-v")) {
- qInfo().noquote() << "IRCaBot" << IRCABOT_VERSION;
- return 0;
- }
- }
- if (configFile.isEmpty()) {
- qInfo().noquote() << "Configuration file not passed. Use -h or --help for usage information.";
- return 1;
- }
- qInfo().noquote() <<
- " /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$$ /$$ \n"
- "|_ $$_/| $$__ $$ /$$__ $$ | $$__ $$ | $$ \n"
- " | $$ | $$ \\ $$| $$ \\__/ /$$$$$$ | $$ \\ $$ /$$$$$$ /$$$$$$ \n"
- " | $$ | $$$$$$$/| $$ |____ $$| $$$$$$$ /$$__ $$|_ $$_/ \n"
- " | $$ | $$__ $$| $$ /$$$$$$$| $$__ $$| $$ \\ $$ | $$ \n"
- " | $$ | $$ \\ $$| $$ $$ /$$__ $$| $$ \\ $$| $$ | $$ | $$ /$$\n"
- " /$$$$$$| $$ | $$| $$$$$$/| $$$$$$$| $$$$$$$/| $$$$$$/ | $$$$/\n"
- "|______/|__/ |__/ \\______/ \\_______/|_______/ \\______/ \\___/";
- qInfo().noquote() << "IRCaBot" << IRCABOT_VERSION << "| Source code: https://notabug.org/acetone/ircabot";
- qInfo().noquote() << "GPLv3 (c) acetone," << COPYRIGHT_YEAR << "\n";
- ApplicationData configuration(configFile);
- auto webInterfaceAddress = configuration.getWebInterfaceAddress();
- HttpServer webInterface(webInterfaceAddress.first,
- webInterfaceAddress.second,
- configuration.getLogFolder(),
- configuration.getMainChannel(),
- configuration.getAjaxIsDisabled());
- auto serversData = configuration.getConnections();
- for (auto server: serversData) {
- if (not server.isOk()) continue;
- IrcClientStarter* wrapper = new IrcClientStarter(server, &webInterface);
- QThread* thread = new QThread;
- wrapper->moveToThread(thread);
- QObject::connect (thread, SIGNAL(started()), wrapper, SLOT(RunInit()));
- thread->start();
- }
- return a.exec();
- }
|