8 #include "helperfuncs.h"
9 #include "u_listmode.h"
11 /* $ModDesc: Provides support for the +e channel mode */
13 /* Written by Om<om@inspircd.org>, April 2005. */
14 /* Rewritten to use the listmode utility by Om, December 2005 */
15 /* Adapted from m_exception, which was originally based on m_chanprotect and m_silence */
17 // The +e channel mode takes a nick!ident@host, glob patterns allowed,
18 // and if a user matches an entry on the +e list then they can join the channel, overriding any (+b) bans set on them
20 class BanException : public ListModeBase
23 BanException(Server* serv) : ListModeBase(serv, 'e', "End of Channel Exception List", "348", "349", true) { }
27 class ModuleBanException : public Module
33 ModuleBanException(Server* serv)
34 : Module::Module(serv)
36 be = new BanException(serv);
38 Srv->AddMode(be, 'e');
41 virtual void Implements(char* List)
43 be->DoImplements(List);
44 List[I_On005Numeric] = List[I_OnCheckBan] = 1;
47 virtual void On005Numeric(std::string &output)
49 output.append(" EXCEPTS=e");
50 InsertMode(output, "e", 1);
53 virtual int OnCheckBan(userrec* user, chanrec* chan)
58 chan->GetExt(be->GetInfoKey(), list);
59 Srv->Log(DEBUG, std::string(user->nick)+" is trying to join "+std::string(chan->name)+", checking for ban exceptions");
63 for (modelist::iterator it = list->begin(); it != list->end(); it++)
64 if(Srv->MatchText(user->GetFullRealHost(), it->mask) || Srv->MatchText(user->GetFullHost(), it->mask))
65 // 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.
74 virtual void OnCleanup(int target_type, void* item)
76 be->DoCleanup(target_type, item);
79 virtual void OnSyncChannel(chanrec* chan, Module* proto, void* opaque)
81 be->DoSyncChannel(chan, proto, opaque);
84 virtual void OnChannelDelete(chanrec* chan)
86 be->DoChannelDelete(chan);
89 virtual void OnRehash(const std::string ¶m)
94 virtual Version GetVersion()
96 return Version(1, 0, 0, 3, VF_STATIC | VF_VENDOR);
99 virtual ~ModuleBanException()
105 class ModuleBanExceptionFactory : public ModuleFactory
108 ModuleBanExceptionFactory()
112 ~ModuleBanExceptionFactory()
116 virtual Module* CreateModule(Server* serv)
118 return new ModuleBanException(serv);
124 extern "C" void * init_module( void )
126 return new ModuleBanExceptionFactory;