1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 /* $Core: libIRCDcull_list */
17 #include "cull_list.h"
19 CullList::CullList(InspIRCd* Instance) : ServerInstance(Instance)
24 void CullList::AddItem(User* user)
28 ServerInstance->Logs->Log("CULLLIST",DEBUG, "*** Warning *** - You tried to quit a user (%s) twice. Did your module call QuitUser twice?", user->nick);
32 user->quitting = true;
36 void CullList::MakeSilent(User* user)
38 user->quietquit = true;
47 while (list.size() && i++ != 100)
49 std::vector<User *>::iterator a = list.begin();
52 user_hash::iterator iter = ServerInstance->Users->clientlist->find(u->nick);
53 const char* preset_reason = u->GetOperQuit();
54 std::string reason = u->quitmsg;
55 std::string oper_reason = *preset_reason ? preset_reason : u->operquitmsg;
57 if (reason.length() > MAXQUIT - 1)
58 reason.resize(MAXQUIT - 1);
59 if (oper_reason.length() > MAXQUIT - 1)
60 oper_reason.resize(MAXQUIT - 1);
62 if (u->registered != REG_ALL)
63 if (ServerInstance->Users->unregistered_count)
64 ServerInstance->Users->unregistered_count--;
68 if ((!u->sendq.empty()) && (!(*u->GetWriteError())))
72 if (u->registered == REG_ALL)
74 FOREACH_MOD_I(ServerInstance,I_OnUserQuit,OnUserQuit(u, reason, oper_reason));
75 u->PurgeEmptyChannels();
76 u->WriteCommonQuit(reason, oper_reason);
79 FOREACH_MOD_I(ServerInstance,I_OnUserDisconnect,OnUserDisconnect(u));
87 u->io->OnRawSocketClose(u->GetFd());
89 catch (CoreException& modexcept)
91 ServerInstance->Logs->Log("CULLLIST",DEBUG, "%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
95 ServerInstance->SE->DelFd(u);
100 * this must come before the ServerInstance->SNO->WriteToSnoMaskso that it doesnt try to fill their buffer with anything
101 * if they were an oper with +sn +qQ.
103 if (u->registered == REG_ALL)
109 ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",u->nick,u->ident,u->host,oper_reason.c_str());
114 if ((!ServerInstance->SilentULine(u->server)) && (!u->quietquit))
116 ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]",u->server,u->nick,u->ident,u->host,oper_reason.c_str());
122 if (iter != ServerInstance->Users->clientlist->end())
126 std::vector<User*>::iterator x = find(ServerInstance->Users->local_users.begin(),ServerInstance->Users->local_users.end(),u);
127 if (x != ServerInstance->Users->local_users.end())
128 ServerInstance->Users->local_users.erase(x);
130 ServerInstance->Users->clientlist->erase(iter);
134 list.erase(list.begin());