X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusermanager.cpp;h=968d5db0017fe282430c9405ae9b0b5e156d9b6f;hb=77730fd5f09f8fc193205654c8bba84d34365670;hp=02c030a42434b1c1414deebe2705e8e05532e432;hpb=d865b434865907bfad0a187dd403d4ca8144e469;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 02c030a42..968d5db00 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -28,21 +28,23 @@ namespace { class WriteCommonQuit : public User::ForEachNeighborHandler { - std::string line; - std::string operline; + ClientProtocol::Messages::Quit quitmsg; + ClientProtocol::Event quitevent; + ClientProtocol::Messages::Quit operquitmsg; + ClientProtocol::Event operquitevent; void Execute(LocalUser* user) CXX11_OVERRIDE { - user->Write(user->IsOper() ? operline : line); + user->Send(user->IsOper() ? operquitevent : quitevent); } public: WriteCommonQuit(User* user, const std::string& msg, const std::string& opermsg) - : line(":" + user->GetFullHost() + " QUIT :") - , operline(line) + : quitmsg(user, msg) + , quitevent(ServerInstance->GetRFCEvents().quit, quitmsg) + , operquitmsg(user, opermsg) + , operquitevent(ServerInstance->GetRFCEvents().quit, operquitmsg) { - line += msg; - operline += opermsg; user->ForEachNeighbor(*this, false); } }; @@ -128,7 +130,11 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs ServerInstance->Logs->Log("BANCACHE", LOG_DEBUG, "BanCache: Positive hit for " + New->GetIPString()); if (!ServerInstance->Config->XLineMessage.empty()) New->WriteNumeric(ERR_YOUREBANNEDCREEP, ServerInstance->Config->XLineMessage); - this->QuitUser(New, b->Reason); + + if (ServerInstance->Config->HideBans) + this->QuitUser(New, b->Type + "-Lined", &b->Reason); + else + this->QuitUser(New, b->Reason); return; } else @@ -177,7 +183,12 @@ void UserManager::QuitUser(User* user, const std::string& quitreason, const std: user->quitting = true; ServerInstance->Logs->Log("USERS", LOG_DEBUG, "QuitUser: %s=%s '%s'", user->uuid.c_str(), user->nick.c_str(), quitreason.c_str()); - user->Write("ERROR :Closing link: (%s@%s) [%s]", user->ident.c_str(), user->GetRealHost().c_str(), operreason ? operreason->c_str() : quitreason.c_str()); + LocalUser* const localuser = IS_LOCAL(user); + if (localuser) + { + ClientProtocol::Messages::Error errormsg(InspIRCd::Format("Closing link: (%s@%s) [%s]", user->ident.c_str(), user->GetRealHost().c_str(), operreason ? operreason->c_str() : quitreason.c_str())); + localuser->Send(ServerInstance->GetRFCEvents().error, errormsg); + } std::string reason; reason.assign(quitreason, 0, ServerInstance->Config->Limits.MaxQuit); @@ -264,12 +275,13 @@ void UserManager::ServerNoticeAll(const char* text, ...) { std::string message; VAFORMAT(message, text, text); - message = "NOTICE $" + ServerInstance->Config->ServerName + " :" + message; + ClientProtocol::Messages::Privmsg msg(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, ServerInstance->Config->ServerName, message, MSG_NOTICE); + ClientProtocol::Event msgevent(ServerInstance->GetRFCEvents().privmsg, msg); for (LocalList::const_iterator i = local_users.begin(); i != local_users.end(); ++i) { - User* t = *i; - t->WriteServ(message); + LocalUser* user = *i; + user->Send(msgevent); } } @@ -320,8 +332,8 @@ void UserManager::DoBackgroundUserStuff() this->QuitUser(curr, message); continue; } - - curr->Write("PING :" + ServerInstance->Config->ServerName); + ClientProtocol::Messages::Ping ping; + curr->Send(ServerInstance->GetRFCEvents().ping, ping); curr->lastping = 0; curr->nping = ServerInstance->Time() + curr->MyClass->GetPingTime(); }