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 * ---------------------------------------------------
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.c_str());
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 std::string& preset_reason = u->GetOperQuit();
55 std::string oper_reason;
57 reason.assign(u->quitmsg, 0, ServerInstance->Config->Limits.MaxQuit);
58 oper_reason.assign(preset_reason.empty() ? preset_reason : u->operquitmsg, 0, ServerInstance->Config->Limits.MaxQuit);
60 if (u->registered != REG_ALL)
61 if (ServerInstance->Users->unregistered_count)
62 ServerInstance->Users->unregistered_count--;
66 if (!u->sendq.empty())
70 if (u->registered == REG_ALL)
72 FOREACH_MOD_I(ServerInstance,I_OnUserQuit,OnUserQuit(u, reason, oper_reason));
73 u->PurgeEmptyChannels();
74 u->WriteCommonQuit(reason, oper_reason);
77 FOREACH_MOD_I(ServerInstance,I_OnUserDisconnect,OnUserDisconnect(u));
85 u->GetIOHook()->OnRawSocketClose(u->GetFd());
87 catch (CoreException& modexcept)
89 ServerInstance->Logs->Log("CULLLIST",DEBUG, "%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
93 ServerInstance->SE->DelFd(u);
98 * this must come before the ServerInstance->SNO->WriteToSnoMaskso that it doesnt try to fill their buffer with anything
99 * if they were an oper with +sn +qQ.
101 if (u->registered == REG_ALL)
107 ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]", u->nick.c_str(), u->ident.c_str(), u->host.c_str(), oper_reason.c_str());
112 if ((!ServerInstance->SilentULine(u->server)) && (!u->quietquit))
114 ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]", u->server, u->nick.c_str(), u->ident.c_str(), u->host.c_str(), oper_reason.c_str());
120 if (iter != ServerInstance->Users->clientlist->end())
122 ServerInstance->Users->clientlist->erase(iter);
126 ServerInstance->Logs->Log("CULLLIST", DEBUG, "iter == clientlist->end, can't remove them from hash... problematic..");
131 std::vector<User*>::iterator x = find(ServerInstance->Users->local_users.begin(),ServerInstance->Users->local_users.end(),u);
132 if (x != ServerInstance->Users->local_users.end())
133 ServerInstance->Users->local_users.erase(x);
136 ServerInstance->Logs->Log("CULLLIST", DEBUG, "Failed to remove user from vector..");
141 list.erase(list.begin());