diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-02-22 20:36:01 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-02-22 20:36:01 +0000 |
commit | fcc5ed3e8ac612ccbbe293c15dee8fcce5fa9ae5 (patch) | |
tree | 268e416ed7b058b12080a81a95600fef3acccd6e /src/modules | |
parent | c10caf3870ff538c609e4a058d4de6f20d0edbd6 (diff) |
Cleanups on module unload or user /QUIT
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3290 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_safelist.cpp | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp index b7bc502f3..c474b9997 100644 --- a/src/modules/m_safelist.cpp +++ b/src/modules/m_safelist.cpp @@ -62,7 +62,7 @@ class ModuleSafeList : public Module void Implements(char* List) { - List[I_OnPreCommand] = List[I_OnBackgroundTimer] = 1; + List[I_OnPreCommand] = List[I_OnBackgroundTimer] = List[I_OnCleanup] = List[I_OnUserQuit] = 1; } /* @@ -175,13 +175,6 @@ class ModuleSafeList : public Module user->Shrink("safelist_last"); } - /* no? let's check when they did a /list last.. */ - /*if ((ld) && (*list_start >= TIME - 100)) - { - Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :*** You are attempting to LIST too quickly. Please wait a while."); - return 1; - }*/ - /* * start at channel 0! ;) */ @@ -201,6 +194,41 @@ class ModuleSafeList : public Module this->OnBackgroundTimer(TIME); return 1; } + + virtual void OnCleanup(int target_type, void* item) + { + if(target_type == TYPE_USER) + { + userrec* u = (userrec*)item; + ListData* ld = u->GetExt("safelist_cache"); + if (ld) + { + u->Shrink("safelist_cache"); + delete ld; + } + for (UserList::iterator iter = listusers.begin(); iter != listusers.end(); iter++) + { + userrec* u2 = (userrec*)(*iter); + if (u2 == u) + { + listusers.erase(iter); + break; + } + } + time_t* last_list_time = (time_t*)user->GetExt("safelist_last"); + if (last_list_time) + { + delete last_list_time; + user->Shrink("safelist_last"); + } + } + } + + virtual void OnUserQuit(userrec* user, std::string message) + { + this->OnCleanup(TYPE_USER,user); + } + }; |