]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_saquit.cpp
A ton more clear() and empty() stuff thats been lingering on the long term todo for...
[user/henk/code/inspircd.git] / src / modules / m_saquit.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "users.h"
16 #include "channels.h"
17 #include "modules.h"
18
19 /* $ModDesc: Provides support for an SAQUIT command, exits user with a reason */
20
21 /** Handle /SAQUIT
22  */
23 class cmd_saquit : public command_t
24 {
25  public:
26  cmd_saquit (InspIRCd* Instance) : command_t(Instance,"SAQUIT",'o',2)
27         {
28                 this->source = "m_saquit.so";
29                 syntax = "<nick> <reason>";
30         }
31
32         CmdResult Handle (const char** parameters, int pcnt, userrec *user)
33         {
34                 userrec* dest = ServerInstance->FindNick(parameters[0]);
35                 if (dest)
36                 {
37                         if (ServerInstance->ULine(dest->server))
38                         {
39                                 user->WriteServ("990 %s :Cannot use an SA command on a u-lined client",user->nick);
40                                 return CMD_FAILURE;
41                         }
42                         irc::stringjoiner reason_join(" ", parameters, 1, pcnt - 1);
43                         std::string line = reason_join.GetJoined();
44
45                         ServerInstance->WriteOpers("*** "+std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+line);
46                         userrec::QuitUser(ServerInstance, dest, line);
47
48                         return CMD_SUCCESS;
49                 }
50                 else
51                 {
52                         user->WriteServ("NOTICE %s :*** Invalid nickname '%s'", user->nick, parameters[0]);
53                 }
54
55                 return CMD_FAILURE;
56         }
57 };
58
59 class ModuleSaquit : public Module
60 {
61         cmd_saquit*     mycommand;
62  public:
63         ModuleSaquit(InspIRCd* Me)
64                 : Module(Me)
65         {
66                 
67                 mycommand = new cmd_saquit(ServerInstance);
68                 ServerInstance->AddCommand(mycommand);
69         }
70         
71         virtual ~ModuleSaquit()
72         {
73         }
74         
75         virtual Version GetVersion()
76         {
77                 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
78         }
79         
80 };
81
82 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
83
84 class ModuleSaquitFactory : public ModuleFactory
85 {
86  public:
87         ModuleSaquitFactory()
88         {
89         }
90         
91         ~ModuleSaquitFactory()
92         {
93         }
94         
95         virtual Module * CreateModule(InspIRCd* Me)
96         {
97                 return new ModuleSaquit(Me);
98         }
99         
100 };
101
102
103 extern "C" DllExport void * init_module( void )
104 {
105         return new ModuleSaquitFactory;
106 }
107