]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_banexception.cpp
Remove an extern, partly because it's unused, partly because it then gets shadowed...
[user/henk/code/inspircd.git] / src / modules / m_banexception.cpp
1 #include <stdio.h>
2 #include <string>
3 #include <vector>
4 #include "users.h"
5 #include "channels.h"
6 #include "modules.h"
7 #include "helperfuncs.h"
8 #include "u_listmode.h"
9
10 /* $ModDesc: Provides support for the +e channel mode */
11
12 /* Written by Om<om@inspircd.org>, April 2005. */
13 /* Rewritten to use the listmode utility by Om, December 2005 */
14 /* Adapted from m_exception, which was originally based on m_chanprotect and m_silence */
15
16 // The +e channel mode takes a nick!ident@host, glob patterns allowed,
17 // and if a user matches an entry on the +e list then they can join the channel, overriding any (+b) bans set on them
18
19
20 class ModuleBanException : public ListModeBaseModule
21 {
22 public:
23         ModuleBanException(Server* serv) : ListModeBaseModule::ListModeBaseModule(serv, 'e', "End of Channel Exception List", "348", "349")
24         {
25         }
26         
27         virtual void Implements(char* List)
28         {
29                 this->DoImplements(List);
30                 List[I_On005Numeric] = List[I_OnCheckBan] = 1;
31         }
32         
33         virtual void On005Numeric(std::string &output)
34         {
35                 output.append(" EXCEPTS=e");
36                 InsertMode(output, "e", 1);
37         }
38
39         virtual int OnCheckBan(userrec* user, chanrec* chan)
40         {
41                 if(chan != NULL)
42                 {
43                         modelist* list = (modelist*)chan->GetExt(infokey);
44                         Srv->Log(DEBUG, std::string(user->nick)+" is trying to join "+std::string(chan->name)+", checking for ban exceptions");
45                         
46                         if(list)
47                         {
48                                 for (modelist::iterator it = list->begin(); it != list->end(); it++)
49                                         if(Srv->MatchText(user->GetFullRealHost(), it->mask) || Srv->MatchText(user->GetFullHost(), it->mask))
50                                                 // They match an entry on the list, so let them in.
51                                                 return 1;
52                                 return 0;
53                         }
54                         // or if there wasn't a list, there can't be anyone on it, so we don't need to do anything.
55                 }
56                 return 0;       
57         }
58         
59         virtual Version GetVersion()
60         {
61                 return Version(1, 0, 0, 3, VF_STATIC | VF_VENDOR);
62         }
63 };
64
65 class ModuleBanExceptionFactory : public ModuleFactory
66 {
67  public:
68         ModuleBanExceptionFactory()
69         {
70         }
71         
72         ~ModuleBanExceptionFactory()
73         {
74         }
75         
76         virtual Module* CreateModule(Server* serv)
77         {
78                 return new ModuleBanException(serv);
79         }
80         
81 };
82
83
84 extern "C" void * init_module( void )
85 {
86         return new ModuleBanExceptionFactory;
87 }