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