8 #include "helperfuncs.h"
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 InviteException : public ListModeBase
25 InviteException(Server* serv) : ListModeBase(serv, 'I', "End of Channel Invite Exception List", "346", "347", true) { }
28 class ModuleInviteException : public Module
34 ModuleInviteException(Server* serv) : Module(serv)
36 ie = new InviteException(serv);
40 virtual void Implements(char* List)
42 ie->DoImplements(List);
43 List[I_On005Numeric] = List[I_OnCheckInvite] = 1;
46 virtual void On005Numeric(std::string &output)
48 output.append(" INVEX=I");
49 InsertMode(output, "I", 1);
52 virtual int OnCheckInvite(userrec* user, chanrec* chan)
56 modelist* list = (modelist*)chan->GetExt(ie->GetInfoKey());
57 Srv->Log(DEBUG, std::string(user->nick)+" is trying to join "+std::string(chan->name)+", checking for invite exceptions");
60 for (modelist::iterator it = list->begin(); it != list->end(); it++)
62 if(Srv->MatchText(user->GetFullRealHost(), it->mask) || Srv->MatchText(user->GetFullHost(), it->mask))
64 // They match an entry on the list, so let them in.
69 // or if there wasn't a list, there can't be anyone on it, so we don't need to do anything.
75 virtual void OnCleanup(int target_type, void* item)
77 ie->DoCleanup(target_type, item);
80 virtual void OnSyncChannel(chanrec* chan, Module* proto, void* opaque)
82 ie->DoSyncChannel(chan, proto, opaque);
85 virtual void OnChannelDelete(chanrec* chan)
87 ie->DoChannelDelete(chan);
90 virtual void OnRehash(const std::string ¶m)
95 virtual Version GetVersion()
97 return Version(1, 0, 0, 3, VF_VENDOR | VF_STATIC);
102 class ModuleInviteExceptionFactory : public ModuleFactory
105 ModuleInviteExceptionFactory()
109 ~ModuleInviteExceptionFactory()
113 virtual Module * CreateModule(Server* serv)
115 return new ModuleInviteException(serv);
121 extern "C" void * init_module( void )
123 return new ModuleInviteExceptionFactory;