diff options
author | Peter Powell <petpow@saberuk.com> | 2013-04-28 12:17:53 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2013-05-14 23:30:12 +0100 |
commit | 226a95aab09b9e1f43f61e78179bfa1135816c2d (patch) | |
tree | 373f6d34cbfbea9e392cb4ab6515aca3a54a6e7e /src/users.cpp | |
parent | b89aa87280767f47381b8a612f73f1d0fe682e2e (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/users.cpp')
-rw-r--r-- | src/users.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/users.cpp b/src/users.cpp index cdc6beed2..7e95dc012 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -388,7 +388,7 @@ bool LocalUser::HasPrivPermission(const std::string &privstr, bool noisy) if (!this->IsOper()) { if (noisy) - this->WriteServ("NOTICE %s :You are not an oper", this->nick.c_str()); + this->WriteNotice("You are not an oper"); return false; } @@ -402,7 +402,8 @@ bool LocalUser::HasPrivPermission(const std::string &privstr, bool noisy) } if (noisy) - this->WriteServ("NOTICE %s :Oper type %s does not have access to priv %s", this->nick.c_str(), oper->NameStr(), privstr.c_str()); + this->WriteNotice("Oper type " + std::string(oper->NameStr()) + " does not have access to priv " + privstr); + return false; } @@ -1047,6 +1048,10 @@ void User::WriteServ(const char* text, ...) this->WriteServ(std::string(textbuffer)); } +void User::WriteNotice(const std::string& text) +{ + this->WriteServ("NOTICE " + (this->registered == REG_ALL ? this->nick : "*") + " :" + text); +} void User::WriteNumeric(unsigned int numeric, const char* text, ...) { |