The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

m_saquit.cpp

Go to the documentation of this file.
00001 /*       +------------------------------------+
00002  *       | Inspire Internet Relay Chat Daemon |
00003  *       +------------------------------------+
00004  *
00005  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
00006  * See: http://www.inspircd.org/wiki/index.php/Credits
00007  *
00008  * This program is free but copyrighted software; see
00009  *            the file COPYING for details.
00010  *
00011  * ---------------------------------------------------
00012  */
00013 
00014 #include "inspircd.h"
00015 
00016 /* $ModDesc: Provides support for an SAQUIT command, exits user with a reason */
00017 
00020 class CommandSaquit : public Command
00021 {
00022  public:
00023         CommandSaquit (InspIRCd* Instance) : Command(Instance, "SAQUIT", "o", 2, 3, false, 0)
00024         {
00025                 this->source = "m_saquit.so";
00026                 syntax = "<nick> <reason>";
00027                 TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
00028         }
00029 
00030         CmdResult Handle (const std::vector<std::string>& parameters, User *user)
00031         {
00032                 User* dest = ServerInstance->FindNick(parameters[0]);
00033                 if (dest)
00034                 {
00035                         if (ServerInstance->ULine(dest->server))
00036                         {
00037                                 user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Cannot use an SA command on a u-lined client",user->nick.c_str());
00038                                 return CMD_FAILURE;
00039                         }
00040 
00041                         ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+parameters[1]);
00042 
00043                         // Pass the command on, so the client's server can quit it properly.
00044                         if (!IS_LOCAL(dest))
00045                                 return CMD_SUCCESS;
00046 
00047                         ServerInstance->Users->QuitUser(dest, parameters[1]);
00048                         return CMD_LOCALONLY;
00049                 }
00050                 else
00051                 {
00052                         user->WriteServ("NOTICE %s :*** Invalid nickname '%s'", user->nick.c_str(), parameters[0].c_str());
00053                 }
00054 
00055                 return CMD_FAILURE;
00056         }
00057 };
00058 
00059 class ModuleSaquit : public Module
00060 {
00061         CommandSaquit*  mycommand;
00062  public:
00063         ModuleSaquit(InspIRCd* Me)
00064                 : Module(Me)
00065         {
00066 
00067                 mycommand = new CommandSaquit(ServerInstance);
00068                 ServerInstance->AddCommand(mycommand);
00069 
00070         }
00071 
00072         virtual ~ModuleSaquit()
00073         {
00074         }
00075 
00076         virtual Version GetVersion()
00077         {
00078                 return Version("$Id: m_saquit.cpp 10718 2008-10-25 16:41:13Z w00t $", VF_COMMON | VF_VENDOR, API_VERSION);
00079         }
00080 
00081 };
00082 
00083 MODULE_INIT(ModuleSaquit)