]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_regonlycreate.cpp
fixed some indentation and spacing in modules
[user/henk/code/inspircd.git] / src / modules / m_regonlycreate.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
16 /* $ModDesc: Prevents users who's nicks are not registered from creating new channels */
17
18 class ModuleRegOnlyCreate : public Module
19 {
20  public:
21         ModuleRegOnlyCreate(InspIRCd* Me)
22                 : Module(Me)
23         {
24                 Implementation eventlist[] = { I_OnUserPreJoin };
25                 ServerInstance->Modules->Attach(eventlist, this, 1);
26         }
27
28
29         virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
30         {
31                 if (chan)
32                         return 0;
33
34                 if (IS_OPER(user))
35                         return 0;
36
37                 if ((!user->IsModeSet('r')) && (!user->GetExt("accountname")))
38                 {
39                         user->WriteNumeric(482, "%s %s :You must have a registered nickname to create a new channel", user->nick.c_str(), cname);
40                         return 1;
41                 }
42
43                 return 0;
44         }
45
46         virtual ~ModuleRegOnlyCreate()
47         {
48         }
49
50         virtual Version GetVersion()
51         {
52                 return Version(1, 2, 0, 0, VF_VENDOR, API_VERSION);
53         }
54 };
55
56 MODULE_INIT(ModuleRegOnlyCreate)