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