]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_operinvex.cpp
Add m_operinvex, adds first use for extended invex (added by Brain). Allows for ...
[user/henk/code/inspircd.git] / src / modules / m_operinvex.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "u_listmode.h"
16
17 /* $ModDep: ../../include/u_listmode.h */
18
19 /* $ModDesc: Implements extban/invex +I O: - opertype bans */
20
21 class ModuleGecosBan : public Module
22 {
23  private:
24  public:
25         ModuleGecosBan(InspIRCd* Me) : Module(Me)
26         {
27                 Implementation eventlist[] = { I_OnUserPreJoin, I_On005Numeric };
28                 ServerInstance->Modules->Attach(eventlist, this, 2);
29         }
30
31         virtual ~ModuleGecosBan()
32         {
33         }
34
35         virtual Version GetVersion()
36         {
37                 return Version("$Id$", VF_VENDOR, API_VERSION);
38         }
39
40         virtual int OnCheckInvite(User *user, Channel *c)
41         {
42                 if (!IS_LOCAL(user) || !IS_OPER(user))
43                         return 0;
44
45                 Module* ExceptionModule = ServerInstance->Modules->Find("m_inviteexception.so");
46                 if (ExceptionModule)
47                 {
48                         if (ListModeRequest(this, ExceptionModule, user->oper, 'O', c).Send())
49                         {
50                                 // Oper type is exempt
51                                 return 1;
52                         }
53                 }
54
55                 return 0;
56         }
57
58         virtual int OnUserPreJoin(User *user, Channel *c, const char *cname, std::string &privs, const std::string &key)
59         {
60                 if (!IS_LOCAL(user) || !IS_OPER(user))
61                         return 0;
62
63                 if (!c)
64                         return 0;
65
66                 if (c->IsExtBanned(user->oper, 'O'))
67                 {
68                         user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Cannot join channel (You're banned)", user->nick.c_str(),  c->name.c_str());
69                         return 1;
70                 }
71
72                 return 0;
73         }
74
75         virtual void On005Numeric(std::string &output)
76         {
77                 ServerInstance->AddExtBanChar('O');
78         }
79 };
80
81
82 MODULE_INIT(ModuleGecosBan)
83