]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_setname.cpp
New 'Implements' system
[user/henk/code/inspircd.git] / src / modules / m_setname.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 <string>
21 #include "users.h"
22 #include "channels.h"
23 #include "modules.h"
24 #include "helperfuncs.h"
25
26 /* $ModDesc: Provides support for the SETNAME command */
27
28 Server *Srv;
29
30 class cmd_setname : public command_t
31 {
32  public:
33         cmd_setname () : command_t("SETNAME", 0, 1)
34         {
35                 this->source = "m_setname.so";
36         }
37
38         void Handle (char **parameters, int pcnt, userrec *user)
39         {
40                 std::string line = "";
41                 for (int i = 0; i < pcnt-1; i++)
42                 {
43                         line = line + std::string(parameters[i]);
44                 }
45                 line = line + std::string(parameters[pcnt-1]);
46                 Srv->ChangeGECOS(user,line);
47         }
48 };
49
50
51 class ModuleSetName : public Module
52 {
53         cmd_setname*    mycommand;
54  public:
55         ModuleSetName(Server* Me)
56                 : Module::Module(Me)
57         {
58                 Srv = Me;
59                 mycommand = new cmd_setname();
60                 Srv->AddCommand(mycommand);
61         }
62         
63         virtual ~ModuleSetName()
64         {
65         }
66         
67         virtual Version GetVersion()
68         {
69                 return Version(1,0,0,1,VF_VENDOR);
70         }
71         
72 };
73
74 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
75
76 class ModuleSetNameFactory : public ModuleFactory
77 {
78  public:
79         ModuleSetNameFactory()
80         {
81         }
82         
83         ~ModuleSetNameFactory()
84         {
85         }
86         
87         virtual Module * CreateModule(Server* Me)
88         {
89                 return new ModuleSetName(Me);
90         }
91         
92 };
93
94
95 extern "C" void * init_module( void )
96 {
97         return new ModuleSetNameFactory;
98 }
99