]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_satopic.cpp
Some more text fixes and improvements (#1618).
[user/henk/code/inspircd.git] / src / modules / m_satopic.cpp
index eec13decc558f870b6980e6b9170d123741bc3a6..dc1e954887313a7a158e946ddde4c5b39f1810ac 100644 (file)
@@ -1,17 +1,21 @@
-/*       +------------------------------------+
- *       | Inspire Internet Relay Chat Daemon |
- *       +------------------------------------+
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
  *
- *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
+ *   Copyright (C) 2008 Oliver Lupton <oliverlupton@gmail.com>
  *
- * This program is free but copyrighted software; see
- *            the file COPYING for details.
+ * This file is part of InspIRCd.  InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
  *
- * ---------------------------------------------------
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/* $ModDesc: Provides a SATOPIC command */
 
 #include "inspircd.h"
 
@@ -22,10 +26,10 @@ class CommandSATopic : public Command
  public:
        CommandSATopic(Module* Creator) : Command(Creator,"SATOPIC", 2, 2)
        {
-               flags_needed = 'o'; Penalty = 0; syntax = "<target> <topic>";
+               flags_needed = 'o'; syntax = "<channel> :<topic>";
        }
 
-       CmdResult Handle (const std::vector<std::string>& parameters, User *user)
+       CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
        {
                /*
                 * Handles a SATOPIC request. Notifies all +s users.
@@ -34,18 +38,21 @@ class CommandSATopic : public Command
 
                if(target)
                {
-                       std::string newTopic = parameters[1];
+                       const std::string newTopic(parameters[1], 0, ServerInstance->Config->Limits.MaxTopic);
+                       if (target->topic == newTopic)
+                       {
+                               user->WriteNotice(InspIRCd::Format("The topic on %s is already what you are trying to change it to.", target->name.c_str()));
+                               return CMD_SUCCESS;
+                       }
 
-                       // 3rd parameter overrides access checks
-                       target->SetTopic(user, newTopic, true);
-                       ServerInstance->SNO->WriteToSnoMask('a', user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
-                       ServerInstance->PI->SendSNONotice("A", user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
+                       target->SetTopic(user, newTopic, ServerInstance->Time(), NULL);
+                       ServerInstance->SNO->WriteGlobalSno('a', user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
 
                        return CMD_SUCCESS;
                }
                else
                {
-                       user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
+                       user->WriteNumeric(Numerics::NoSuchChannel(parameters[0]));
                        return CMD_FAILURE;
                }
        }
@@ -57,17 +64,12 @@ class ModuleSATopic : public Module
  public:
        ModuleSATopic()
        : cmd(this)
-       {
-               ServerInstance->AddCommand(&cmd);
-       }
-
-       virtual ~ModuleSATopic()
        {
        }
 
-       virtual Version GetVersion()
+       Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Provides a SATOPIC command", VF_VENDOR);
+               return Version("Provides the SATOPIC command", VF_VENDOR);
        }
 };