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