]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_sanick.cpp
Fixed compile problems... Move along please, nothing to see here..
[user/henk/code/inspircd.git] / src / modules / m_sanick.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
25 /* $ModDesc: Provides support for SANICK command */
26
27 Server *Srv;
28
29 class cmd_sanick : public command_t
30 {
31  public:
32         cmd_sanick () : command_t("SANICK", 'o', 2)
33         {
34                 this->source = "m_sanick.so";
35         }
36
37         void Handle (char **parameters, int pcnt, userrec *user)
38         {
39                 userrec* source = Srv->FindNick(std::string(parameters[0]));
40                 if (source)
41                 {
42                         if (Srv->IsNick(std::string(parameters[1])))
43                         {
44                                 // FIX by brain: Cant use source->nick here because if it traverses a server link then
45                                 // source->nick becomes invalid as the object data moves in memory.
46                                 Srv->SendOpers(std::string(user->nick)+" used SANICK to change "+std::string(parameters[0])+" to "+parameters[1]);
47                                 Srv->ChangeUserNick(source,std::string(parameters[1]));
48                         }
49                 }
50         }
51 };
52
53
54 class ModuleSanick : public Module
55 {
56         cmd_sanick*     mycommand;
57  public:
58         ModuleSanick(Server* Me)
59                 : Module::Module(Me)
60         {
61                 Srv = Me;
62                 mycommand = new cmd_sanick();
63                 Srv->AddCommand(mycommand);
64         }
65         
66         virtual ~ModuleSanick()
67         {
68         }
69         
70         virtual Version GetVersion()
71         {
72                 return Version(1,0,0,1,VF_VENDOR);
73         }
74         
75 };
76
77 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
78
79 class ModuleSanickFactory : public ModuleFactory
80 {
81  public:
82         ModuleSanickFactory()
83         {
84         }
85         
86         ~ModuleSanickFactory()
87         {
88         }
89         
90         virtual Module * CreateModule(Server* Me)
91         {
92                 return new ModuleSanick(Me);
93         }
94         
95 };
96
97
98 extern "C" void * init_module( void )
99 {
100         return new ModuleSanickFactory;
101 }
102