summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2013-04-28 12:17:53 +0100
committerPeter Powell <petpow@saberuk.com>2013-05-14 23:30:12 +0100
commit226a95aab09b9e1f43f61e78179bfa1135816c2d (patch)
tree373f6d34cbfbea9e392cb4ab6515aca3a54a6e7e /src/commands
parentb89aa87280767f47381b8a612f73f1d0fe682e2e (diff)
Add method for writing server notices.
This allows us to send a server notice to a user without worrying about whether they are registered or not. If a user receives a server notice and they are not registered then the nickname field will contain an asterisk instead of their nick name.
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/cmd_eline.cpp14
-rw-r--r--src/commands/cmd_gline.cpp8
-rw-r--r--src/commands/cmd_hostname_lookup.cpp16
-rw-r--r--src/commands/cmd_kline.cpp8
-rw-r--r--src/commands/cmd_qline.cpp6
-rw-r--r--src/commands/cmd_rehash.cpp2
-rw-r--r--src/commands/cmd_zline.cpp6
7 files changed, 30 insertions, 30 deletions
diff --git a/src/commands/cmd_eline.cpp b/src/commands/cmd_eline.cpp
index 6fd94d1b8..67f67e9f0 100644
--- a/src/commands/cmd_eline.cpp
+++ b/src/commands/cmd_eline.cpp
@@ -60,11 +60,11 @@ CmdResult CommandEline::Handle (const std::vector<std::string>& parameters, User
else
ih = ServerInstance->XLines->IdentSplit(target);
- if (ih.first.empty())
- {
- user->WriteServ("NOTICE %s :*** Target not found", user->nick.c_str());
- return CMD_FAILURE;
- }
+ if (ih.first.empty())
+ {
+ user->WriteNotice("*** Target not found");
+ return CMD_FAILURE;
+ }
if (ServerInstance->HostMatchesEveryone(ih.first+"@"+ih.second,user))
return CMD_FAILURE;
@@ -88,7 +88,7 @@ CmdResult CommandEline::Handle (const std::vector<std::string>& parameters, User
else
{
delete el;
- user->WriteServ("NOTICE %s :*** E-Line for %s already exists",user->nick.c_str(),target.c_str());
+ user->WriteNotice("*** E-Line for " + target + " already exists");
}
}
else
@@ -99,7 +99,7 @@ CmdResult CommandEline::Handle (const std::vector<std::string>& parameters, User
}
else
{
- user->WriteServ("NOTICE %s :*** E-Line %s not found in list, try /stats e.",user->nick.c_str(),target.c_str());
+ user->WriteNotice("*** E-Line " + target + " not found in list, try /stats e");
}
}
diff --git a/src/commands/cmd_gline.cpp b/src/commands/cmd_gline.cpp
index 25330ffe2..bdb5c26b2 100644
--- a/src/commands/cmd_gline.cpp
+++ b/src/commands/cmd_gline.cpp
@@ -63,7 +63,7 @@ CmdResult CommandGline::Handle (const std::vector<std::string>& parameters, User
if (ih.first.empty())
{
- user->WriteServ("NOTICE %s :*** Target not found", user->nick.c_str());
+ user->WriteNotice("*** Target not found");
return CMD_FAILURE;
}
@@ -72,7 +72,7 @@ CmdResult CommandGline::Handle (const std::vector<std::string>& parameters, User
else if (target.find('!') != std::string::npos)
{
- user->WriteServ("NOTICE %s :*** G-Line cannot operate on nick!user@host masks",user->nick.c_str());
+ user->WriteNotice("*** G-Line cannot operate on nick!user@host masks");
return CMD_FAILURE;
}
@@ -97,7 +97,7 @@ CmdResult CommandGline::Handle (const std::vector<std::string>& parameters, User
else
{
delete gl;
- user->WriteServ("NOTICE %s :*** G-Line for %s already exists",user->nick.c_str(),target.c_str());
+ user->WriteNotice("** G-Line for " + target + " already exists");
}
}
@@ -109,7 +109,7 @@ CmdResult CommandGline::Handle (const std::vector<std::string>& parameters, User
}
else
{
- user->WriteServ("NOTICE %s :*** G-line %s not found in list, try /stats g.",user->nick.c_str(),target.c_str());
+ user->WriteNotice("*** G-Line " + target + " not found in list, try /stats g.");
}
}
diff --git a/src/commands/cmd_hostname_lookup.cpp b/src/commands/cmd_hostname_lookup.cpp
index d43730b94..3bbd58eb1 100644
--- a/src/commands/cmd_hostname_lookup.cpp
+++ b/src/commands/cmd_hostname_lookup.cpp
@@ -94,7 +94,7 @@ class UserResolver : public DNS::Request
delete res_forward;
ServerInstance->Logs->Log("RESOLVER", LOG_DEBUG,"Error in resolver: %s",e.GetReason());
- bound_user->WriteServ("NOTICE Auth :*** There was an internal error resolving your host, using your IP address (%s) instead.", bound_user->GetIPString().c_str());
+ bound_user->WriteNotice("*** There was an internal error resolving your host, using your IP address (" + bound_user->GetIPString() + ") instead.");
dl->set(bound_user, 0);
}
}
@@ -130,7 +130,7 @@ class UserResolver : public DNS::Request
if (hostname == NULL)
{
ServerInstance->Logs->Log("RESOLVER", LOG_DEFAULT, "ERROR: User has no hostname attached when doing a forward lookup");
- bound_user->WriteServ("NOTICE Auth :*** There was an internal error resolving your host, using your IP address (%s) instead.", bound_user->GetIPString().c_str());
+ bound_user->WriteNotice("*** There was an internal error resolving your host, using your IP address (" + bound_user->GetIPString() + ") instead.");
return;
}
else if (hostname->length() < 65)
@@ -139,7 +139,7 @@ class UserResolver : public DNS::Request
if ((*hostname)[0] == ':')
hostname->insert(0, "0");
- bound_user->WriteServ("NOTICE Auth :*** Found your hostname (%s)%s", hostname->c_str(), (r->cached ? " -- cached" : ""));
+ bound_user->WriteNotice("*** Found your hostname (" + *hostname + (r->cached ? ") -- cached" : ")"));
bound_user->host.assign(*hostname, 0, 64);
bound_user->dhost = bound_user->host;
@@ -148,14 +148,14 @@ class UserResolver : public DNS::Request
}
else
{
- bound_user->WriteServ("NOTICE Auth :*** Your hostname is longer than the maximum of 64 characters, using your IP address (%s) instead.", bound_user->GetIPString().c_str());
+ bound_user->WriteNotice("*** Your hostname is longer than the maximum of 64 characters, using your IP address (" + bound_user->GetIPString() + ") instead.");
}
ph->unset(bound_user);
}
else
{
- bound_user->WriteServ("NOTICE Auth :*** Your hostname does not match up with your IP address. Sorry, using your IP address (%s) instead.", bound_user->GetIPString().c_str());
+ bound_user->WriteNotice("*** Your hostname does not match up with your IP address. Sorry, using your IP address (" + bound_user->GetIPString() + ") instead.");
}
}
}
@@ -168,7 +168,7 @@ class UserResolver : public DNS::Request
LocalUser* bound_user = (LocalUser*)ServerInstance->FindUUID(uuid);
if (bound_user)
{
- bound_user->WriteServ("NOTICE Auth :*** Could not resolve your hostname: %s; using your IP address (%s) instead.", this->manager->GetErrorStr(query->error).c_str(), bound_user->GetIPString().c_str());
+ bound_user->WriteNotice("*** Could not resolve your hostname: " + this->manager->GetErrorStr(query->error) + "; using your IP address (" + bound_user->GetIPString() + ") instead.");
dl->set(bound_user, 0);
ServerInstance->stats->statsDnsBad++;
}
@@ -205,11 +205,11 @@ class ModuleHostnameLookup : public Module
{
if (!DNS || user->MyClass->nouserdns)
{
- user->WriteServ("NOTICE %s :*** Skipping host resolution (disabled by server administrator)", user->nick.c_str());
+ user->WriteNotice("*** Skipping host resolution (disabled by server administrator)");
return;
}
- user->WriteServ("NOTICE Auth :*** Looking up your hostname...");
+ user->WriteNotice("*** Looking up your hostname...");
UserResolver* res_reverse = new UserResolver(*this->DNS, this, user, user->GetIPString(), DNS::QUERY_PTR);
try
diff --git a/src/commands/cmd_kline.cpp b/src/commands/cmd_kline.cpp
index 34920a4bf..20afae2a9 100644
--- a/src/commands/cmd_kline.cpp
+++ b/src/commands/cmd_kline.cpp
@@ -63,7 +63,7 @@ CmdResult CommandKline::Handle (const std::vector<std::string>& parameters, User
if (ih.first.empty())
{
- user->WriteServ("NOTICE %s :*** Target not found", user->nick.c_str());
+ user->WriteNotice("*** Target not found");
return CMD_FAILURE;
}
@@ -72,7 +72,7 @@ CmdResult CommandKline::Handle (const std::vector<std::string>& parameters, User
if (target.find('!') != std::string::npos)
{
- user->WriteServ("NOTICE %s :*** K-Line cannot operate on nick!user@host masks",user->nick.c_str());
+ user->WriteNotice("*** K-Line cannot operate on nick!user@host masks");
return CMD_FAILURE;
}
@@ -97,7 +97,7 @@ CmdResult CommandKline::Handle (const std::vector<std::string>& parameters, User
else
{
delete kl;
- user->WriteServ("NOTICE %s :*** K-Line for %s already exists",user->nick.c_str(),target.c_str());
+ user->WriteNotice("*** K-Line for " + target + " already exists");
}
}
else
@@ -108,7 +108,7 @@ CmdResult CommandKline::Handle (const std::vector<std::string>& parameters, User
}
else
{
- user->WriteServ("NOTICE %s :*** K-Line %s not found in list, try /stats k.",user->nick.c_str(),target.c_str());
+ user->WriteNotice("*** K-Line " + target + " not found in list, try /stats k.");
}
}
diff --git a/src/commands/cmd_qline.cpp b/src/commands/cmd_qline.cpp
index 2443ed66c..bfc9e4519 100644
--- a/src/commands/cmd_qline.cpp
+++ b/src/commands/cmd_qline.cpp
@@ -48,7 +48,7 @@ CmdResult CommandQline::Handle (const std::vector<std::string>& parameters, User
if (parameters[0].find('@') != std::string::npos || parameters[0].find('!') != std::string::npos || parameters[0].find('.') != std::string::npos)
{
- user->WriteServ("NOTICE %s :*** A Q-Line only bans a nick pattern, not a nick!user@host pattern.",user->nick.c_str());
+ user->WriteNotice("*** A Q-Line only bans a nick pattern, not a nick!user@host pattern.");
return CMD_FAILURE;
}
@@ -72,7 +72,7 @@ CmdResult CommandQline::Handle (const std::vector<std::string>& parameters, User
else
{
delete ql;
- user->WriteServ("NOTICE %s :*** Q-Line for %s already exists",user->nick.c_str(),parameters[0].c_str());
+ user->WriteNotice("*** Q-Line for " + parameters[0] + " already exists");
}
}
else
@@ -83,7 +83,7 @@ CmdResult CommandQline::Handle (const std::vector<std::string>& parameters, User
}
else
{
- user->WriteServ("NOTICE %s :*** Q-Line %s not found in list, try /stats q.",user->nick.c_str(),parameters[0].c_str());
+ user->WriteNotice("*** Q-Line " + parameters[0] + " not found in list, try /stats q.");
return CMD_FAILURE;
}
}
diff --git a/src/commands/cmd_rehash.cpp b/src/commands/cmd_rehash.cpp
index 1ad96d794..923bfe129 100644
--- a/src/commands/cmd_rehash.cpp
+++ b/src/commands/cmd_rehash.cpp
@@ -101,7 +101,7 @@ CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, Use
* XXX, todo: we should find some way to kill runaway rehashes that are blocking, this is a major problem for unrealircd users
*/
if (IS_LOCAL(user))
- user->WriteServ("NOTICE %s :*** Could not rehash: A rehash is already in progress.", user->nick.c_str());
+ user->WriteNotice("*** Could not rehash: A rehash is already in progress.");
else
ServerInstance->PI->SendUserNotice(user, "*** Could not rehash: A rehash is already in progress.");
}
diff --git a/src/commands/cmd_zline.cpp b/src/commands/cmd_zline.cpp
index 5027c94c7..fdb156e0a 100644
--- a/src/commands/cmd_zline.cpp
+++ b/src/commands/cmd_zline.cpp
@@ -49,7 +49,7 @@ CmdResult CommandZline::Handle (const std::vector<std::string>& parameters, User
{
if (target.find('!') != std::string::npos)
{
- user->WriteServ("NOTICE %s :*** You cannot include a nickname in a zline, a zline must ban only an IP mask",user->nick.c_str());
+ user->WriteNotice("*** You cannot include a nickname in a zline, a zline must ban only an IP mask");
return CMD_FAILURE;
}
@@ -92,7 +92,7 @@ CmdResult CommandZline::Handle (const std::vector<std::string>& parameters, User
else
{
delete zl;
- user->WriteServ("NOTICE %s :*** Z-Line for %s already exists",user->nick.c_str(),ipaddr);
+ user->WriteNotice("*** Z-Line for " + std::string(ipaddr) + " already exists");
}
}
else
@@ -103,7 +103,7 @@ CmdResult CommandZline::Handle (const std::vector<std::string>& parameters, User
}
else
{
- user->WriteServ("NOTICE %s :*** Z-Line %s not found in list, try /stats Z.",user->nick.c_str(),target.c_str());
+ user->WriteNotice("*** Z-Line " + target + " not found in list, try /stats Z.");
return CMD_FAILURE;
}
}