]> 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 4a6f855369276dba2b3fb6fd865571e0454a9713..dc1e954887313a7a158e946ddde4c5b39f1810ac 100644 (file)
@@ -26,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.
@@ -38,15 +38,21 @@ class CommandSATopic : public Command
 
                if(target)
                {
-                       const std::string& newTopic = parameters[1];
-                       target->SetTopic(user, newTopic);
+                       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;
+                       }
+
+                       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(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
+                       user->WriteNumeric(Numerics::NoSuchChannel(parameters[0]));
                        return CMD_FAILURE;
                }
        }
@@ -63,7 +69,7 @@ class ModuleSATopic : public Module
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Provides a SATOPIC command", VF_VENDOR);
+               return Version("Provides the SATOPIC command", VF_VENDOR);
        }
 };