summaryrefslogtreecommitdiff
path: root/src/command.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2017-01-23 12:35:14 -0500
committerAdam <Adam@anope.org>2017-01-23 12:35:14 -0500
commit16ca76c2e7ab287e480185fbb03a0bb438351eda (patch)
treedfb25534afa2352b65b2ee707086cb5eecc96fbb /src/command.cpp
parentff030c1eb7c3764f9add2a689479e84d616cabcb (diff)
Make log system use newer format strings
Also allow log messages to be translatable
Diffstat (limited to 'src/command.cpp')
-rw-r--r--src/command.cpp39
1 files changed, 32 insertions, 7 deletions
diff --git a/src/command.cpp b/src/command.cpp
index 7a87b07f3..9095c0526 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -31,8 +31,12 @@
#include "modules/botserv.h"
#include "modules/chanserv.h"
-CommandSource::CommandSource(const Anope::string &n, User *user, NickServ::Account *core, CommandReply *r, ServiceBot *bi) : nick(n), u(user), nc(core), reply(r),
- c(NULL), service(bi)
+CommandSource::CommandSource(const Anope::string &n, User *user, NickServ::Account *core, CommandReply *r, ServiceBot *bi)
+ : nick(n)
+ , u(user)
+ , nc(core)
+ , reply(r)
+ , service(bi)
{
}
@@ -51,6 +55,24 @@ NickServ::Account *CommandSource::GetAccount()
return this->nc;
}
+Anope::string CommandSource::GetSource()
+{
+ if (u)
+ if (nc)
+ return this->u->GetMask() + " (" + this->nc->GetDisplay() + ")";
+ else
+ return this->u->GetMask();
+ else if (nc)
+ return nc->GetDisplay();
+ else
+ return this->nick;
+}
+
+const Anope::string &CommandSource::GetCommand() const
+{
+ return this->command;
+}
+
ChanServ::AccessGroup CommandSource::AccessFor(ChanServ::Channel *ci)
{
if (this->u)
@@ -120,9 +142,12 @@ void CommandSource::Reply(const Anope::string &message)
this->reply->SendMessage(*this->service, tok);
}
-Command::Command(Module *o, const Anope::string &sname, size_t minparams, size_t maxparams) : Service(o, NAME, sname), max_params(maxparams), min_params(minparams), module(o)
+Command::Command(Module *o, const Anope::string &sname, size_t minparams, size_t maxparams) : Service(o, NAME, sname)
+ , max_params(maxparams)
+ , min_params(minparams)
+ , module(o)
+ , logger(this)
{
- allow_unregistered = require_user = false;
}
Command::~Command()
@@ -234,7 +259,7 @@ void Command::Run(CommandSource &source, const Anope::string &message)
source.Reply(_("Unknown command \002{0}\002. \"{1}{2} HELP\" for help."), message, Config->StrictPrivmsg, source.service->nick);
else
source.Reply(_("Unknown command \002{0}\002."), message);
- Log(source.service) << "Command " << it->first << " exists on me, but its service " << info.name << " was not found!";
+ source.service->logger.Log("Command {0} exists on me, but its service {1} was not found!", it->first, info.name);
return;
}
@@ -260,7 +285,7 @@ void Command::Run(CommandSource &source, const Anope::string &cmdname, const Com
{
source.Reply(_("Password authentication required for that command."));
if (source.GetUser())
- Log(LOG_NORMAL, "access_denied_unreg", source.service) << "Access denied for unregistered user " << source.GetUser()->GetMask() << " with command " << cmdname;
+ Anope::Logger.User(source.service).Category("access_denied_unreg").Log(_("Access denied for unregistered user {0} with command {1}"), source.GetUser()->GetMask(), cmdname);
return;
}
@@ -285,7 +310,7 @@ void Command::Run(CommandSource &source, const Anope::string &cmdname, const Com
else
source.Reply(_("Access denied. You do not have access to command \002{0}\002."), info.permission);
if (source.GetUser())
- Log(LOG_NORMAL, "access_denied", source.service) << "Access denied for user " << source.GetUser()->GetMask() << " with command " << cmdname;
+ Anope::Logger.User(source.service).Category("access_denied").Log(_("Access denied for user {0} with command {1}"), source.GetUser()->GetMask(), cmdname);
return;
}