added authentication
This commit is contained in:
parent
afa0b3f90f
commit
e943dc185b
@ -176,11 +176,28 @@ bool RPGModule::messageHandler(Message msg)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(msg.args.startsWith("travel "))
|
||||||
|
{
|
||||||
|
QStringList paramList = msg.args.split(' ');
|
||||||
|
if(charOnline.count(src) > 0 && paramList.size() == 2)
|
||||||
|
{
|
||||||
|
answer = say(playerTravel(charOnline[src], paramList[1]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(msg.args.startsWith("look "))
|
||||||
|
{
|
||||||
|
// look around
|
||||||
|
|
||||||
|
// look at [object]
|
||||||
|
}
|
||||||
else if(msg.args.compare("!rpg help") == 0)
|
else if(msg.args.compare("!rpg help") == 0)
|
||||||
{
|
{
|
||||||
answer = privateSay("Create new character (works only in private message) : !rpg register [name of character] [password]", msg.nick);
|
answer = privateSay("Create new character (works only in private message) : !rpg register [name of character] [password]", msg.nick);
|
||||||
answer += privateSay("Join game with character (works only in private message) : !rpg join [name of character] [password]", msg.nick);
|
answer += privateSay("Join game with character (works only in private message) : !rpg join [name of character] [password]", msg.nick);
|
||||||
answer += privateSay("leave the game : !rpg leave", msg.nick);
|
answer += privateSay("leave the game : !rpg leave", msg.nick);
|
||||||
|
answer += privateSay("show your stats : !rpg stats", msg.nick);
|
||||||
|
answer += privateSay("show all in-game players : !rpg list", msg.nick);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,8 @@ bool BaseModule::messageHandler(Message msg)
|
|||||||
if(msg.command.compare("376") == 0)
|
if(msg.command.compare("376") == 0)
|
||||||
{
|
{
|
||||||
status = ON_CHAN;
|
status = ON_CHAN;
|
||||||
|
if(!getPass().isNull())
|
||||||
|
answer += privateSay(QString("identify %1 %2").arg(getNick()).arg(getPass()), "nickserv");
|
||||||
answer += join(getChan());
|
answer += join(getChan());
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ BotApp::BotApp(int argc, char** argv) : nogui(false)
|
|||||||
int port = 6667;
|
int port = 6667;
|
||||||
QString nick = QString("SparrowBotDebug");
|
QString nick = QString("SparrowBotDebug");
|
||||||
QString chan = QString("epicsparrow");
|
QString chan = QString("epicsparrow");
|
||||||
|
QString pass;
|
||||||
|
|
||||||
// parsing arguments
|
// parsing arguments
|
||||||
for(int i=1; i<argc; ++i)
|
for(int i=1; i<argc; ++i)
|
||||||
@ -31,12 +32,14 @@ BotApp::BotApp(int argc, char** argv) : nogui(false)
|
|||||||
nick = argList.at(1);
|
nick = argList.at(1);
|
||||||
else if(key.compare("chan") == 0)
|
else if(key.compare("chan") == 0)
|
||||||
chan = argList.at(1);
|
chan = argList.at(1);
|
||||||
|
else if(key.compare("pass") == 0)
|
||||||
|
pass = argList.at(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sock = new SocketIRC(server, port);
|
sock = new SocketIRC(server, port);
|
||||||
bot = new IRCBot(nick, chan);
|
bot = new IRCBot(nick, chan, pass);
|
||||||
if(nogui)
|
if(nogui)
|
||||||
coreApp = new QCoreApplication(argc, argv);
|
coreApp = new QCoreApplication(argc, argv);
|
||||||
else
|
else
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "basemodule.h"
|
#include "basemodule.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
|
||||||
IRCBot::IRCBot(QString nick_, QString chan_) : nick(nick_), chan(chan_)
|
IRCBot::IRCBot(QString nick_, QString chan_, QString pass_) : nick(nick_), chan(chan_), pass(pass_)
|
||||||
{
|
{
|
||||||
addModule(new BaseModule());
|
addModule(new BaseModule());
|
||||||
}
|
}
|
||||||
@ -28,6 +28,7 @@ void IRCBot::addModule(Module* module)
|
|||||||
modules.push_back(module);
|
modules.push_back(module);
|
||||||
module->setChan(chan);
|
module->setChan(chan);
|
||||||
module->setNick(nick);
|
module->setNick(nick);
|
||||||
|
module->setPass(pass);
|
||||||
module->setModuleList(&modules);
|
module->setModuleList(&modules);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,11 +14,12 @@ class IRCBot : public QObject
|
|||||||
|
|
||||||
QString nick;
|
QString nick;
|
||||||
QString chan;
|
QString chan;
|
||||||
|
QString pass;
|
||||||
|
|
||||||
std::vector<Module*> modules;
|
std::vector<Module*> modules;
|
||||||
BaseModule *base;
|
BaseModule *base;
|
||||||
public:
|
public:
|
||||||
IRCBot(QString nick_, QString chan_);
|
IRCBot(QString nick_, QString chan_, QString pass_ = QString());
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void addModule(Module* module);
|
void addModule(Module* module);
|
||||||
|
@ -22,6 +22,11 @@ QString Module::getNick()
|
|||||||
return nick;
|
return nick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Module::getPass()
|
||||||
|
{
|
||||||
|
return pass;
|
||||||
|
}
|
||||||
|
|
||||||
QString Module::getChan()
|
QString Module::getChan()
|
||||||
{
|
{
|
||||||
return chan;
|
return chan;
|
||||||
@ -54,6 +59,11 @@ void Module::setNick(QString nick_)
|
|||||||
nick = nick_;
|
nick = nick_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Module::setPass(QString pass_)
|
||||||
|
{
|
||||||
|
pass = pass_;
|
||||||
|
}
|
||||||
|
|
||||||
void Module::setChan(QString chan_)
|
void Module::setChan(QString chan_)
|
||||||
{
|
{
|
||||||
chan = chan_;
|
chan = chan_;
|
||||||
|
@ -12,6 +12,7 @@ class Module
|
|||||||
private:
|
private:
|
||||||
bool enabled;
|
bool enabled;
|
||||||
QString nick;
|
QString nick;
|
||||||
|
QString pass;
|
||||||
QString chan;
|
QString chan;
|
||||||
std::vector<Module*>* modules;
|
std::vector<Module*>* modules;
|
||||||
|
|
||||||
@ -19,6 +20,7 @@ protected:
|
|||||||
QString answer;
|
QString answer;
|
||||||
|
|
||||||
QString getNick();
|
QString getNick();
|
||||||
|
QString getPass();
|
||||||
QString getChan();
|
QString getChan();
|
||||||
int getNbModules();
|
int getNbModules();
|
||||||
Module* getModule(int index);
|
Module* getModule(int index);
|
||||||
@ -42,6 +44,7 @@ public:
|
|||||||
bool isEnabled();
|
bool isEnabled();
|
||||||
void setEnabled(bool newStatus);
|
void setEnabled(bool newStatus);
|
||||||
void setNick(QString nick_);
|
void setNick(QString nick_);
|
||||||
|
void setPass(QString pass_);
|
||||||
void setChan(QString chan_);
|
void setChan(QString chan_);
|
||||||
void setModuleList(std::vector<Module*>* modList);
|
void setModuleList(std::vector<Module*>* modList);
|
||||||
//TODO: add serialization methods
|
//TODO: add serialization methods
|
||||||
|
Loading…
x
Reference in New Issue
Block a user