From 28dcc1f9e017152f03b0d9bfbcc494260b015a0a Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Thu, 25 Feb 2016 15:25:02 +0100 Subject: Add Numeric::Numeric --- src/users.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src') diff --git a/src/users.cpp b/src/users.cpp index fd4afbcef..915afd8b8 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -786,6 +786,22 @@ void User::WriteCommand(const char* command, const std::string& text) this->WriteServ(command + (this->registered & REG_NICK ? " " + this->nick : " *") + " " + text); } +namespace +{ + std::string BuildNumeric(const std::string& source, User* targetuser, unsigned int num, const std::vector& params) + { + const char* const target = (targetuser->registered & REG_NICK ? targetuser->nick.c_str() : "*"); + std::string raw = InspIRCd::Format(":%s %03u %s", source.c_str(), num, target); + if (!params.empty()) + { + for (std::vector::const_iterator i = params.begin(); i != params.end()-1; ++i) + raw.append(1, ' ').append(*i); + raw.append(" :").append(params.back()); + } + return raw; + } +} + void User::WriteNumeric(unsigned int numeric, const char* text, ...) { std::string textbuffer; -- cgit v1.2.3