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