9 #include "u_listmode.h"
11 /* $ModDesc: Provides support for the +I channel mode */
14 * Written by Om <om@inspircd.org>, April 2005.
15 * Based on m_exception, which was originally based on m_chanprotect and m_silence
17 * The +I channel mode takes a nick!ident@host, glob patterns allowed,
18 * and if a user matches an entry on the +I list then they can join the channel,
19 * ignoring if +i is set on the channel
22 class InspIRCd* ServerInstance;
24 /** Handles channel mode +I
26 class InviteException : public ListModeBase
29 InviteException(InspIRCd* Instance) : ListModeBase(Instance, 'I', "End of Channel Invite Exception List", "346", "347", true) { }
32 class ModuleInviteException : public Module
36 ModuleInviteException(InspIRCd* Me) : Module(Me)
38 ie = new InviteException(ServerInstance);
39 ServerInstance->AddMode(ie, 'I');
42 virtual void Implements(char* List)
44 ie->DoImplements(List);
45 List[I_On005Numeric] = List[I_OnCheckInvite] = 1;
48 virtual void On005Numeric(std::string &output)
50 output.append(" INVEX=I");
53 virtual int OnCheckInvite(userrec* user, chanrec* chan)
58 chan->GetExt(ie->GetInfoKey(), list);
61 for (modelist::iterator it = list->begin(); it != list->end(); it++)
63 if(match(user->GetFullRealHost(), it->mask.c_str()) || match(user->GetFullHost(), it->mask.c_str()))
65 // They match an entry on the list, so let them in.
70 // or if there wasn't a list, there can't be anyone on it, so we don't need to do anything.
76 virtual void OnCleanup(int target_type, void* item)
78 ie->DoCleanup(target_type, item);
81 virtual void OnSyncChannel(chanrec* chan, Module* proto, void* opaque)
83 ie->DoSyncChannel(chan, proto, opaque);
86 virtual void OnChannelDelete(chanrec* chan)
88 ie->DoChannelDelete(chan);
91 virtual void OnRehash(const std::string ¶m)
96 virtual Version GetVersion()
98 return Version(1, 0, 0, 3, VF_VENDOR | VF_COMMON);
101 ~ModuleInviteException()
103 ServerInstance->Modes->DelMode(ie);
109 class ModuleInviteExceptionFactory : public ModuleFactory
112 ModuleInviteExceptionFactory()
116 ~ModuleInviteExceptionFactory()
120 virtual Module * CreateModule(InspIRCd* Me)
122 return new ModuleInviteException(Me);
128 extern "C" void * init_module( void )
130 return new ModuleInviteExceptionFactory;