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_satopic.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 /* $ModDesc: Provides a SATOPIC command */
00015 
00016 #include "inspircd.h"
00017 
00020 class CommandSATopic : public Command
00021 {
00022  public:
00023         CommandSATopic (InspIRCd* Instance)
00024         : Command(Instance,"SATOPIC", "o", 2, 2, false, 0)
00025         {
00026                 this->source = "m_satopic.so";
00027                 syntax = "<target> <topic>";
00028         }
00029 
00030         CmdResult Handle (const std::vector<std::string>& parameters, User *user)
00031         {
00032                 /*
00033                  * Handles a SATOPIC request. Notifies all +s users.
00034                  */
00035                 Channel* target = ServerInstance->FindChan(parameters[0]);
00036 
00037                 if(target)
00038                 {
00039                         std::string newTopic = parameters[1];
00040                         
00041                         // 3rd parameter overrides access checks
00042                         target->SetTopic(user, newTopic, true);
00043                         ServerInstance->SNO->WriteToSnoMask('A', user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
00044                         ServerInstance->PI->SendSNONotice("A", user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
00045 
00046                         return CMD_LOCALONLY;
00047                 }
00048                 else
00049                 {
00050                         user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
00051                         return CMD_FAILURE;
00052                 }
00053         }
00054 };
00055 
00056 class ModuleSATopic : public Module
00057 {
00058         CommandSATopic* mycommand;
00059  public:
00060         ModuleSATopic(InspIRCd* Me)
00061         : Module(Me)
00062         {
00063                 mycommand = new CommandSATopic(ServerInstance);
00064                 ServerInstance->AddCommand(mycommand);
00065         }
00066 
00067         virtual ~ModuleSATopic()
00068         {
00069         }
00070 
00071         virtual Version GetVersion()
00072         {
00073                 return Version("$Id: m_satopic.cpp 10718 2008-10-25 16:41:13Z w00t $", VF_VENDOR, API_VERSION);
00074         }
00075 };
00076 
00077 MODULE_INIT(ModuleSATopic)