]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_samode.cpp
Tidy up strlens which are not required
[user/henk/code/inspircd.git] / src / modules / m_samode.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 /*
20  * SAMODE module for InspIRCd
21  *  Co authored by Brain and w00t
22  *
23  *  Syntax: /SAMODE <#chan/nick> +/-<modes> [parameters for modes]
24  * 
25  */
26
27 /* $ModDesc: Povides more advanced UnrealIRCd SAMODE command */
28
29 /*
30  * ToDo:
31  *   Err... not a lot really.
32  */ 
33
34 #include <stdio.h>
35 #include "users.h"
36 #include "channels.h"
37 #include "modules.h"
38 #include "inspircd.h"
39
40
41
42          
43 class cmd_samode : public command_t
44 {
45  public:
46         cmd_samode (InspIRCd* Instance) : command_t(Instance,"SAMODE", 'o', 2)
47         {
48                 this->source = "m_samode.so";
49                 syntax = "<target> <modes> {<mode-parameters>}";
50         }
51
52         CmdResult Handle (const char** parameters, int pcnt, userrec *user)
53         {
54                 /*
55                  * Handles an SAMODE request. Notifies all +s users.
56                  */
57
58                 userrec* n = new userrec(ServerInstance);
59                 n->SetFd(FD_MAGIC_NUMBER);
60                 ServerInstance->SendMode(parameters,pcnt,n);
61                 delete n;
62
63                 if (ServerInstance->Modes->GetLastParse().length())
64                         ServerInstance->WriteOpers(std::string(user->nick)+" used SAMODE: "+ServerInstance->Modes->GetLastParse());
65
66                 return CMD_SUCCESS;
67         }
68 };
69
70 class ModuleSaMode : public Module
71 {
72         cmd_samode*     mycommand;
73  public:
74         ModuleSaMode(InspIRCd* Me)
75                 : Module::Module(Me)
76         {
77                 
78                 mycommand = new cmd_samode(ServerInstance);
79                 ServerInstance->AddCommand(mycommand);
80         }
81         
82         virtual ~ModuleSaMode()
83         {
84         }
85         
86         virtual Version GetVersion()
87         {
88                 return Version(1,0,2,2,VF_VENDOR,API_VERSION);
89         }
90 };
91
92
93 class ModuleSaModeFactory : public ModuleFactory
94 {
95  public:
96         ModuleSaModeFactory()
97         {
98         }
99         
100         ~ModuleSaModeFactory()
101         {
102         }
103         
104         virtual Module * CreateModule(InspIRCd* Me)
105         {
106                 return new ModuleSaMode(Me);
107         }
108         
109 };
110
111
112 extern "C" void * init_module( void )
113 {
114         return new ModuleSaModeFactory;
115 }