]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nonicks.cpp
added m_noinvite that uses the new OnUserPreInvite method
[user/henk/code/inspircd.git] / src / modules / m_nonicks.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #include <stdio.h>
18 #include <string>
19 #include "users.h"
20 #include "channels.h"
21 #include "modules.h"
22
23 /* $ModDesc: Provides support for unreal-style GLOBOPS and umode +g */
24
25 Server *Srv;
26
27 class ModuleNoNickChange : public Module
28 {
29  public:
30         ModuleNoNickChange()
31         {
32                 Srv = new Server;
33                 
34                 Srv->AddExtendedMode('N',MT_CHANNEL,false,0,0);
35         }
36         
37         virtual ~ModuleNoNickChange()
38         {
39                 delete Srv;
40         }
41         
42         virtual Version GetVersion()
43         {
44                 return Version(1,0,0,1);
45         }
46         
47         virtual int OnUserPreNick(userrec* user, std::string newnick)
48         {
49                 if (!strcasecmp(user->server,Srv->GetServerName().c_str()))
50                 {
51                         for (int i =0; i != MAXCHANS; i++)
52                         {
53                                 if (user->chans[i].channel != NULL)
54                                 {
55                                         chanrec* curr = user->chans[i].channel;
56                                         if (curr->IsCustomModeSet('N'))
57                                         {
58                                                 if (!strchr(user->modes,'o'))
59                                                 {
60                                                         // don't allow the nickchange, theyre on at least one channel with +N set
61                                                         // and theyre not an oper
62                                                         WriteServ(user->fd,"447 %s :Can't change nickname while on %s (+N is set)",user->nick,curr->name);
63                                                         return 1;
64                                                 }
65                                         }
66                                 }
67                         }
68                 }
69                 return 0;
70         }
71         
72         virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
73         {
74                 // check if this is our mode character...
75                 if ((modechar == 'N') && (type == MT_CHANNEL))
76                 {
77                         return 1;
78                 }
79                 else
80                 {
81                         return 0;
82                 }
83         }
84
85 };
86
87 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
88
89 class ModuleNoNickChangeFactory : public ModuleFactory
90 {
91  public:
92         ModuleNoNickChangeFactory()
93         {
94         }
95         
96         ~ModuleNoNickChangeFactory()
97         {
98         }
99         
100         virtual Module * CreateModule()
101         {
102                 return new ModuleNoNickChange;
103         }
104         
105 };
106
107
108 extern "C" void * init_module( void )
109 {
110         return new ModuleNoNickChangeFactory;
111 }
112