diff options
author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-11-03 02:05:45 +0000 |
---|---|---|
committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-11-03 02:05:45 +0000 |
commit | 921ddbd517a8575205931b10ad66f6607e0f5890 (patch) | |
tree | ed5a0c0f138fdeb16db52a95db51fe8d57ace2f1 | |
parent | 65deeaf1e61242da81ca62059bcc3d5a342edcb6 (diff) |
Added OnPreNickExpire and OnPreChanExpire events, which can keep nicks and channels from expiring
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2605 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r-- | include/modules.h | 16 | ||||
-rw-r--r-- | src/chanserv.c | 9 | ||||
-rw-r--r-- | src/nickserv.c | 5 |
3 files changed, 27 insertions, 3 deletions
diff --git a/include/modules.h b/include/modules.h index 021276dce..1befc9250 100644 --- a/include/modules.h +++ b/include/modules.h @@ -683,6 +683,12 @@ class CoreExport Module */ virtual void OnTopicUpdated(Channel *c, const char *topic) { } + /** Called before a channel expires + * @param ci The channel + * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it + */ + virtual EventReturn OnPreChanExpire(ChannelInfo *ci) { return EVENT_CONTINUE; } + /** Called when a channel expires * @param chname The channel name */ @@ -727,6 +733,12 @@ class CoreExport Module */ virtual void OnSignal(const char *msg) { } + /** Called before a nick expires + * @param na The nick + * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it + */ + virtual EventReturn OnPreNickExpire(NickAlias *na) { return EVENT_CONTINUE; } + /** Called when a nick drops * @param nick The nick */ @@ -992,13 +1004,13 @@ enum Implementation { I_BEGIN, /* NickServ */ - I_OnNickExpire, I_OnNickForbidden, I_OnNickGroup, I_OnNickLogout, I_OnNickIdentify, I_OnNickDrop, + I_OnPreNickExpire, I_OnNickExpire, I_OnNickForbidden, I_OnNickGroup, I_OnNickLogout, I_OnNickIdentify, I_OnNickDrop, I_OnNickRegister, I_OnNickSuspended, I_OnNickUnsuspended, I_OnFindUser, I_OnFindNick, I_OnDelNick, I_OnFindCore, I_OnDelCore, I_OnChangeCoreDisplay, I_OnFindRequestNick, I_OnDelNickRequest, I_OnMakeNickRequest, I_OnNickClearAccess, I_OnNickEraseAccess, /* ChanServ */ - I_OnChanForbidden, I_OnChanSuspend, I_OnChanDrop, I_OnChanExpire, I_OnAccessAdd, I_OnAccessChange, + I_OnChanForbidden, I_OnChanSuspend, I_OnChanDrop, I_OnPreChanExpire, I_OnChanExpire, I_OnAccessAdd, I_OnAccessChange, I_OnAccessDel, I_OnAccessClear, I_OnChanRegistered, I_OnChanUnsuspend, I_OnDelChan, I_OnChannelCreate, I_OnChannelDelete, diff --git a/src/chanserv.c b/src/chanserv.c index 991b708ef..dc0cca07f 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -1449,10 +1449,17 @@ void expire_chans() && !(ci-> flags & (CI_FORBIDDEN | CI_NO_EXPIRE | CI_SUSPENDED))) { - FOREACH_MOD(I_OnChanExpire, OnChanExpire(ci->name)); + EventReturn MOD_RESULT; + FOREACH_RESULT(I_OnPreChanExpire, OnPreChanExpire(ci)); + if (MOD_RESULT == EVENT_STOP) + continue; + + char *chname = sstrdup(ci->name); alog("Expiring channel %s (founder: %s)", ci->name, (ci->founder ? ci->founder->display : "(none)")); delchan(ci); + FOREACH_MOD(I_OnChanExpire, OnChanExpire(chname)); + delete [] chname; } } } diff --git a/src/nickserv.c b/src/nickserv.c index de9b6de88..a6489bbc3 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -797,6 +797,11 @@ void expire_nicks() && !(na->status & (NS_FORBIDDEN | NS_NO_EXPIRE)) && !(na->nc->flags & (NI_SUSPENDED))) { + EventReturn MOD_RESULT; + FOREACH_RESULT(I_OnPreNickExpire, OnPreNickExpire(na)); + if (MOD_RESULT == EVENT_STOP) + continue; + alog("Expiring nickname %s (group: %s) (e-mail: %s)", na->nick, na->nc->display, (na->nc->email ? na->nc->email : "none")); |