]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_samode.cpp
5fa694ddd14eb17aa804ff6927a7b37c8ed8cacc
[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: Provides 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 /** Handle /SAMODE
41  */
42 class cmd_samode : public command_t
43 {
44  public:
45         cmd_samode (InspIRCd* Instance) : command_t(Instance,"SAMODE", 'o', 2)
46         {
47                 this->source = "m_samode.so";
48                 syntax = "<target> <modes> {<mode-parameters>}";
49         }
50
51         CmdResult Handle (const char** parameters, int pcnt, userrec *user)
52         {
53                 /*
54                  * Handles an SAMODE request. Notifies all +s users.
55                  */
56
57                 userrec* n = new userrec(ServerInstance);
58                 n->SetFd(FD_MAGIC_NUMBER);
59                 ServerInstance->SendMode(parameters,pcnt,n);
60                 delete n;
61
62                 if (ServerInstance->Modes->GetLastParse().length())
63                 {
64                         ServerInstance->WriteOpers(std::string(user->nick)+" used SAMODE: "+ServerInstance->Modes->GetLastParse());
65                         return CMD_SUCCESS;
66                 }
67
68                 return CMD_FAILURE;
69         }
70 };
71
72 class ModuleSaMode : public Module
73 {
74         cmd_samode*     mycommand;
75  public:
76         ModuleSaMode(InspIRCd* Me)
77                 : Module::Module(Me)
78         {
79                 
80                 mycommand = new cmd_samode(ServerInstance);
81                 ServerInstance->AddCommand(mycommand);
82         }
83         
84         virtual ~ModuleSaMode()
85         {
86         }
87         
88         virtual Version GetVersion()
89         {
90                 return Version(1,1,2,2,VF_VENDOR,API_VERSION);
91         }
92 };
93
94
95 class ModuleSaModeFactory : public ModuleFactory
96 {
97  public:
98         ModuleSaModeFactory()
99         {
100         }
101         
102         ~ModuleSaModeFactory()
103         {
104         }
105         
106         virtual Module * CreateModule(InspIRCd* Me)
107         {
108                 return new ModuleSaMode(Me);
109         }
110         
111 };
112
113
114 extern "C" void * init_module( void )
115 {
116         return new ModuleSaModeFactory;
117 }