]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_inviteexception.cpp
AMD64 warning 'fix' which tested fine when I added it seems to now...stop things...
[user/henk/code/inspircd.git] / src / modules / m_inviteexception.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 +I channel mode */
11
12 /*
13  * Written by Om <om@inspircd.org>, April 2005.
14  * Based on m_exception, which was originally based on m_chanprotect and m_silence
15  *
16  * The +I channel mode takes a nick!ident@host, glob patterns allowed,
17  * and if a user matches an entry on the +I list then they can join the channel,
18  * ignoring if +i is set on the channel
19  */
20
21 class ModuleInviteException : public ListModeBaseModule
22 {
23 public:
24         ModuleInviteException(Server* serv) : ListModeBaseModule::ListModeBaseModule(serv, 'I', "End of Channel Invite Exception List", "346", "347")
25         {
26         }
27         
28         virtual void Implements(char* List)
29         {
30                 this->DoImplements(List);
31                 List[I_On005Numeric] = List[I_OnCheckInvite] = 1;
32         }
33         
34         virtual void On005Numeric(std::string &output)
35         {
36                 output.append(" INVEX=I");
37                 InsertMode(output, "I", 1);
38         }
39          
40         virtual int OnCheckInvite(userrec* user, chanrec* chan)
41         {
42                 if(chan != NULL)
43                 {
44                         modelist* list = (modelist*)chan->GetExt(infokey);
45                         Srv->Log(DEBUG, std::string(user->nick)+" is trying to join "+std::string(chan->name)+", checking for invite exceptions");
46                         if (list)
47                         {
48                                 for (modelist::iterator it = list->begin(); it != list->end(); it++)
49                                 {
50                                         if(Srv->MatchText(user->GetFullRealHost(), it->mask) || Srv->MatchText(user->GetFullHost(), it->mask))
51                                         {
52                                                 // They match an entry on the list, so let them in.
53                                                 return 1;
54                                         }
55                                 }
56                         }
57                         // or if there wasn't a list, there can't be anyone on it, so we don't need to do anything.
58                 }
59
60                 return 0;               
61         }
62                 
63         virtual Version GetVersion()
64         {
65                 return Version(1, 0, 0, 3, VF_VENDOR | VF_STATIC);
66         }
67 };
68
69
70 class ModuleInviteExceptionFactory : public ModuleFactory
71 {
72  public:
73         ModuleInviteExceptionFactory()
74         {
75         }
76         
77         ~ModuleInviteExceptionFactory()
78         {
79         }
80         
81         virtual Module * CreateModule(Server* serv)
82         {
83                 return new ModuleInviteException(serv);
84         }
85         
86 };
87
88
89 extern "C" void * init_module( void )
90 {
91         return new ModuleInviteExceptionFactory;
92 }