From 800c7ddd7368c469415f5db13cb8c9c4bcc0966a Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 9 Jul 2006 15:39:50 +0000 Subject: Port to new API git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4226 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_noinvite.cpp | 51 ++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 17 deletions(-) (limited to 'src/modules/m_noinvite.cpp') diff --git a/src/modules/m_noinvite.cpp b/src/modules/m_noinvite.cpp index a0caade2a..86b960b63 100644 --- a/src/modules/m_noinvite.cpp +++ b/src/modules/m_noinvite.cpp @@ -24,22 +24,51 @@ using namespace std; /* $ModDesc: Provides support for unreal-style channel mode +V */ +class NoInvite : public ModeHandler +{ + public: + NoInvite() : ModeHandler('V', 0, 0, false, MODETYPE_CHANNEL, false) { } + + ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) + { + if (adding) + { + if (!channel->IsModeSet('V')) + { + channel->SetMode('V',true); + return MODEACTION_ALLOW; + } + } + else + { + if (channel->IsModeSet('V')) + { + channel->SetMode('V',false); + return MODEACTION_ALLOW; + } + } + + return MODEACTION_DENY; + } +}; + class ModuleNoInvite : public Module { Server *Srv; + NoInvite *ni; public: - ModuleNoInvite(Server* Me) - : Module::Module(Me) + ModuleNoInvite(Server* Me) : Module::Module(Me) { Srv = Me; - Srv->AddExtendedMode('V',MT_CHANNEL,false,0,0); + ni = new NoInvite(); + Srv->AddMode(ni, 'V'); } void Implements(char* List) { - List[I_On005Numeric] = List[I_OnUserPreInvite] = List[I_OnExtendedMode] = 1; + List[I_On005Numeric] = List[I_OnUserPreInvite] = 1; } virtual void On005Numeric(std::string &output) @@ -57,22 +86,10 @@ class ModuleNoInvite : public Module } return 0; } - - virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms) - { - // check if this is our mode character... - if ((modechar == 'V') && (type == MT_CHANNEL)) - { - return 1; - } - else - { - return 0; - } - } virtual ~ModuleNoInvite() { + DELETE(ni); } virtual Version GetVersion() -- cgit v1.2.3