]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_restrictchans.cpp
Added preliminary m_sqllog.cpp
[user/henk/code/inspircd.git] / src / modules / m_restrictchans.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 "users.h"
19 #include "channels.h"
20 #include "modules.h"
21
22 /* $ModDesc: Only opers may create new channels if this module is loaded */
23
24 Server *Srv;
25          
26 class ModuleRestrictChans : public Module
27 {
28  public:
29         ModuleRestrictChans()
30         {
31                 Srv = new Server;
32         }
33         
34         virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
35         {
36                 // user is not an oper
37                 if (!strchr(user->modes,'o'))
38                 {
39                         // channel does not yet exist (record is null, about to be created IF we were to allow it)
40                         if (!chan)
41                         {
42                                 WriteServ(user->fd,"530 %s %s :Only IRC operators may create new channels",user->nick,cname,cname);
43                                 return 1;
44                         }
45                 }
46                 return 0;
47         }
48         
49         virtual ~ModuleRestrictChans()
50         {
51                 delete Srv;
52         }
53         
54         virtual Version GetVersion()
55         {
56                 return Version(1,0,0,1,VF_VENDOR);
57         }
58 };
59
60
61 class ModuleRestrictChansFactory : public ModuleFactory
62 {
63  public:
64         ModuleRestrictChansFactory()
65         {
66         }
67         
68         ~ModuleRestrictChansFactory()
69         {
70         }
71         
72         virtual Module * CreateModule()
73         {
74                 return new ModuleRestrictChans;
75         }
76         
77 };
78
79
80 extern "C" void * init_module( void )
81 {
82         return new ModuleRestrictChansFactory;
83 }
84