]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_channel/cmd_topic.cpp
Merge pull request #1271 from SaberUK/master+exemption
[user/henk/code/inspircd.git] / src / coremods / core_channel / cmd_topic.cpp
index b421489399953867c169af5712d60a418d5e9d05..ec6ed974490dadc4499eef374a140a9202c19af7 100644 (file)
@@ -25,6 +25,7 @@
 
 CommandTopic::CommandTopic(Module* parent)
        : SplitCommand(parent, "TOPIC", 1, 2)
+       , exemptionprov(parent)
        , secretmode(parent, "secret")
        , topiclockmode(parent, "topiclock")
 {
@@ -73,14 +74,25 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters,
                        user->WriteNumeric(ERR_NOTONCHANNEL, c->name, "You're not on that channel!");
                        return CMD_FAILURE;
                }
-               if (c->IsModeSet(topiclockmode) && !ServerInstance->OnCheckExemption(user, c, "topiclock").check(c->GetPrefixValue(user) >= HALFOP_VALUE))
+               if (c->IsModeSet(topiclockmode))
                {
-                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, c->name, "You do not have access to change the topic on this channel");
-                       return CMD_FAILURE;
+                       ModResult MOD_RESULT;
+                       FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, MOD_RESULT, (user, c, "topiclock"));
+                       if (!MOD_RESULT.check(c->GetPrefixValue(user) >= HALFOP_VALUE))
+                       {
+                               user->WriteNumeric(ERR_CHANOPRIVSNEEDED, c->name, "You do not have access to change the topic on this channel");
+                               return CMD_FAILURE;
+                       }
                }
        }
 
-       c->SetTopic(user, t);
+       // Make sure the topic is not longer than the limit in the config
+       if (t.length() > ServerInstance->Config->Limits.MaxTopic)
+               t.erase(ServerInstance->Config->Limits.MaxTopic);
+
+       // Only change if the new topic is different than the current one
+       if (c->topic != t)
+               c->SetTopic(user, t, ServerInstance->Time());
        return CMD_SUCCESS;
 }