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