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