diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-09 14:53:49 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-09 14:53:49 +0000 |
commit | 1e25e3d54a7d6f3634edcd3a4bd29fddb4d9865c (patch) | |
tree | a3a3398bb2f57690dc1ac58b02885171d74377bc /src | |
parent | 7b4b3f5d11fbfa272f58021df0094586c0fa4b09 (diff) |
Fixed for new API
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4222 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_kicknorejoin.cpp | 61 |
1 files changed, 35 insertions, 26 deletions
diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index 3910bc030..770b79db3 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -6,6 +6,7 @@ #include "channels.h" #include "modules.h" #include "helperfuncs.h" +#include "inspircd.h" /* $ModDesc: Provides channel mode +J (delay rejoin after kick) */ @@ -19,9 +20,39 @@ inline int strtoint(const std::string &str) typedef std::map<userrec*, time_t> delaylist; +class KickRejoin : public ModeHandler +{ + public: + KickRejoin() : ModeHandler('J', 1, 0, false, MODETYPE_CHANNEL, false) { } + + ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) + { + if (!adding) + { + // Taking the mode off, we need to clean up. + delaylist* dl = (delaylist*)channel->GetExt("norejoinusers"); + + if (dl) + { + DELETE(dl); + channel->Shrink("norejoinusers"); + } + } + if ((!adding) || (atoi(parameter.c_str()) > 0)) + { + return MODEACTION_ALLOW; + } + else + { + return MODEACTION_DENY; + } + } +}; + class ModuleKickNoRejoin : public Module { Server *Srv; + KickRejoin* kr; public: @@ -29,31 +60,8 @@ public: : Module::Module(Me) { Srv = Me; - - Srv->AddExtendedMode('J', MT_CHANNEL, false, 1, 0); - } - - virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms) - { - if ((modechar == 'J') && (type == MT_CHANNEL)) - { - if (!mode_on) - { - // Taking the mode off, we need to clean up. - chanrec* c = (chanrec*)target; - - delaylist* dl = (delaylist*)c->GetExt("norejoinusers"); - - if (dl) - { - DELETE(dl); - c->Shrink("norejoinusers"); - } - } - /* Don't allow negative or 0 +J value */ - return ((!mode_on) || (atoi(params[0].c_str()) > 0)); - } - return 0; + kr = new KickRejoin(); + Srv->AddMode(kr, 'J'); } virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) @@ -139,7 +147,7 @@ public: virtual void Implements(char* List) { - List[I_OnCleanup] = List[I_On005Numeric] = List[I_OnExtendedMode] = List[I_OnChannelDelete] = List[I_OnUserPreJoin] = List[I_OnUserKick] = 1; + List[I_OnCleanup] = List[I_On005Numeric] = List[I_OnChannelDelete] = List[I_OnUserPreJoin] = List[I_OnUserKick] = 1; } virtual void On005Numeric(std::string &output) @@ -149,6 +157,7 @@ public: virtual ~ModuleKickNoRejoin() { + DELETE(kr); } virtual Version GetVersion() |