]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_cban.cpp
Fixed compile problems... Move along please, nothing to see here..
[user/henk/code/inspircd.git] / src / modules / m_cban.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2005 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: Gives /cban, aka C:lines. Think Q:lines, for channels. */
26
27 Server *Srv;
28
29 class cmd_cban : public command_t
30 {
31         public:
32         cmd_cban () : command_t("CBAN", 'o', 1)
33         {
34                 this->source = "m_cban.so";
35         }
36
37         void Handle(char **parameters, int pcnt, userrec *user)
38         {
39                 /* syntax: CBAN #channel time :reason goes here */
40                 /* 'time' is a human-readable timestring, like 2d3h2s. */
41
42                 if (pcnt == 1)
43                 {
44                         /* form: CBAN #channel removes a CBAN */
45                 }
46                 else if (pcnt >= 2)
47                 {
48                         /* full form to add a CBAN */
49                 }
50         }
51 };
52
53 class ModuleCBan : public Module
54 {
55         cmd_cban* mycommand;
56         vector<std::string> cbans;
57
58  public:
59         ModuleCBan(Server* Me) : Module::Module(Me)
60         {
61                 Srv = Me;
62                 mycommand = new cmd_cban();
63                 Srv->AddCommand(mycommand);
64         }
65
66         virtual int OnUserPreJoin (userrec *user, chanrec *chan, const char *cname)
67         {
68                 /* check cbans in here, and apply as necessary. */
69
70                 std::string chname = cname;
71
72                 for (vector<std::string>::iterator iterate = cbans.begin(); iterate < cbans.end(); iterate++)
73                 {
74                         if (chname == *iterate)
75                         {
76                                 /* matches CBAN */
77                                 return 1;
78                         }
79                 }
80
81                 /* Allow the change. */
82                 return 0;
83         }
84
85         virtual ~ModuleCBan()
86         {
87         }
88         
89         virtual Version GetVersion()
90         {
91                 return Version(1,0,0,0,VF_VENDOR);
92         }
93 };
94
95
96 class ModuleCBanFactory : public ModuleFactory
97 {
98  public:
99         ModuleCBanFactory()
100         {
101         }
102         
103         ~ModuleCBanFactory()
104         {
105         }
106         
107         virtual Module * CreateModule(Server* Me)
108         {
109                 return new ModuleCBan(Me);
110         }
111         
112 };
113
114
115 extern "C" void * init_module( void )
116 {
117         return new ModuleCBanFactory;
118 }
119