]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_regonlycreate.cpp
5a85f4d655f501f93bf8d7590921d8e2e8609b83
[user/henk/code/inspircd.git] / src / modules / m_regonlycreate.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 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 "users.h"
16 #include "channels.h"
17 #include "modules.h"
18
19 /* $ModDesc: Prevents users who's nicks are not registered from creating new channels */
20
21 class ModuleRegOnlyCreate : public Module
22 {
23  public:
24         ModuleRegOnlyCreate(InspIRCd* Me)
25                 : Module(Me)
26         {
27         }
28
29         void Implements(char* List)
30         {
31                 List[I_OnUserPreJoin] = 1;
32         }
33
34         virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs)
35         {
36                 if (chan)
37                         return 0;
38
39                 if (IS_OPER(user))
40                         return 0;
41
42                 if ((!user->IsModeSet('r')) && (!user->GetExt("accountname")))
43                 {
44                         user->WriteServ("482 %s %s :You must have a registered nickname to create a new channel", user->nick, cname);
45                         return 1;
46                 }
47
48                 return 0;
49         }
50         
51         virtual ~ModuleRegOnlyCreate()
52         {
53         }
54         
55         virtual Version GetVersion()
56         {
57                 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
58         }
59 };
60
61
62 class ModuleRegOnlyCreateFactory : public ModuleFactory
63 {
64  public:
65         ModuleRegOnlyCreateFactory()
66         {
67         }
68         
69         ~ModuleRegOnlyCreateFactory()
70         {
71         }
72         
73         virtual Module * CreateModule(InspIRCd* Me)
74         {
75                 return new ModuleRegOnlyCreate(Me);
76         }
77         
78 };
79
80
81 extern "C" DllExport void * init_module( void )
82 {
83         return new ModuleRegOnlyCreateFactory;
84 }
85