]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/cull_list.cpp
Remove /summon and /users (I think 15+ years of being marked deprecated is enough...
[user/henk/code/inspircd.git] / src / cull_list.cpp
index c1a9de1a08baf8b9bb8180c70df4815b272e4a1b..9aecb8d837220b9195242b652e5fadae2aa49e7f 100644 (file)
  */
 
 #include "inspircd.h"
-#include "users.h"
 #include "cull_list.h"
 
 CullItem::CullItem(userrec* u, std::string &r, const char* o_reason)
 {
        this->user = u;
        this->reason = r;
+       this->silent = false;
        /* Seperate oper reason not set, use the user reason */
        if (*o_reason)
                this->oper_reason = o_reason;
@@ -30,6 +30,7 @@ CullItem::CullItem(userrec* u, const char* r, const char* o_reason)
 {
        this->user = u;
        this->reason = r;
+       this->silent = false;
        /* Seperate oper reason not set, use the user reason */
        if (*o_reason)
                this->oper_reason = o_reason;
@@ -37,6 +38,16 @@ CullItem::CullItem(userrec* u, const char* r, const char* o_reason)
                this->oper_reason = r;
 }
 
+void CullItem::MakeSilent()
+{
+       this->silent = true;
+}
+
+bool CullItem::IsSilent()
+{
+       return this->silent;
+}
+
 CullItem::~CullItem()
 {
 }
@@ -78,6 +89,19 @@ void CullList::AddItem(userrec* user, const char* reason, const char* o_reason)
        }
 }
 
+void CullList::MakeSilent(userrec* user)
+{
+       for (std::vector<CullItem>::iterator a = list.begin(); a != list.end(); ++a)
+       {
+               if (a->GetUser() == user)
+               {
+                       a->MakeSilent();
+                       break;
+               }
+       }
+       return;
+}
+
 int CullList::Apply()
 {
        int n = list.size();
@@ -87,8 +111,9 @@ int CullList::Apply()
 
                user_hash::iterator iter = ServerInstance->clientlist->find(a->GetUser()->nick);
                std::map<userrec*, userrec*>::iterator exemptiter = exempt.find(a->GetUser());
+               const char* preset_reason = a->GetUser()->GetOperQuit();
                std::string reason = a->GetReason();
-               std::string oper_reason = a->GetOperReason();
+               std::string oper_reason = *preset_reason ? preset_reason : a->GetOperReason();
 
                if (reason.length() > MAXQUIT - 1)
                        reason.resize(MAXQUIT - 1);
@@ -101,16 +126,16 @@ int CullList::Apply()
 
                if (IS_LOCAL(a->GetUser()))
                {
-                       a->GetUser()->Write("ERROR :Closing link (%s@%s) [%s]",a->GetUser()->ident,a->GetUser()->host,reason.c_str());
+                       a->GetUser()->Write("ERROR :Closing link (%s@%s) [%s]", a->GetUser()->ident, a->GetUser()->host, oper_reason.c_str());
                        if ((!a->GetUser()->sendq.empty()) && (!(*a->GetUser()->GetWriteError())))
                                a->GetUser()->FlushWriteBuf();
                }
 
                if (a->GetUser()->registered == REG_ALL)
                {
+                       FOREACH_MOD_I(ServerInstance,I_OnUserQuit,OnUserQuit(a->GetUser(), reason, oper_reason));
                        a->GetUser()->PurgeEmptyChannels();
                        a->GetUser()->WriteCommonQuit(reason, oper_reason);
-                       FOREACH_MOD_I(ServerInstance,I_OnUserQuit,OnUserQuit(a->GetUser(),reason));
                }
 
                FOREACH_MOD_I(ServerInstance,I_OnUserDisconnect,OnUserDisconnect(a->GetUser()));
@@ -140,9 +165,19 @@ int CullList::Apply()
                if (a->GetUser()->registered == REG_ALL)
                {
                        if (IS_LOCAL(a->GetUser()))
-                               ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",a->GetUser()->nick,a->GetUser()->ident,a->GetUser()->host,reason.c_str());
+                       {
+                               if (!a->IsSilent())
+                               {
+                                       ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",a->GetUser()->nick,a->GetUser()->ident,a->GetUser()->host,oper_reason.c_str());
+                               }
+                       }
                        else
-                               ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]",a->GetUser()->server,a->GetUser()->nick,a->GetUser()->ident,a->GetUser()->host,reason.c_str());
+                       {
+                               if ((!ServerInstance->SilentULine(a->GetUser()->server)) && (!a->IsSilent()))
+                               {
+                                       ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]",a->GetUser()->server,a->GetUser()->nick,a->GetUser()->ident,a->GetUser()->host,oper_reason.c_str());
+                               }
+                       }
                        a->GetUser()->AddToWhoWas();
                }
 
@@ -163,3 +198,4 @@ int CullList::Apply()
        }
        return n;
 }
+