summaryrefslogtreecommitdiff
path: root/src/usermanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/usermanager.cpp')
-rw-r--r--src/usermanager.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/usermanager.cpp b/src/usermanager.cpp
index 52cb4989f..5d07c4d79 100644
--- a/src/usermanager.cpp
+++ b/src/usermanager.cpp
@@ -24,6 +24,30 @@
#include "xline.h"
#include "iohook.h"
+namespace
+{
+ class WriteCommonQuit : public User::ForEachNeighborHandler
+ {
+ std::string line;
+ std::string operline;
+
+ void Execute(LocalUser* user) CXX11_OVERRIDE
+ {
+ user->Write(user->IsOper() ? operline : line);
+ }
+
+ public:
+ WriteCommonQuit(User* user, const std::string& msg, const std::string& opermsg)
+ : line(":" + user->GetFullHost() + " QUIT :")
+ , operline(line)
+ {
+ line += msg;
+ operline += opermsg;
+ user->ForEachNeighbor(*this, false);
+ }
+ };
+}
+
UserManager::UserManager()
: unregistered_count(0)
{
@@ -180,7 +204,7 @@ void UserManager::QuitUser(User* user, const std::string& quitreason, const std:
if (user->registered == REG_ALL)
{
FOREACH_MOD(OnUserQuit, (user, reason, *operreason));
- user->WriteCommonQuit(reason, *operreason);
+ WriteCommonQuit(user, reason, *operreason);
}
else
unregistered_count--;