]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_channel/cmd_topic.cpp
Merge insp20
[user/henk/code/inspircd.git] / src / coremods / core_channel / cmd_topic.cpp
index 2b0f81fb68077dea2d084809373f90cd75ca0404..8d65d764a1a7aac3e75854cf3723d4134a8bb0bf 100644 (file)
 
 
 #include "inspircd.h"
+#include "core_channel.h"
 
-/** Handle /TOPIC.
- */
-class CommandTopic : public SplitCommand
+CommandTopic::CommandTopic(Module* parent)
+       : SplitCommand(parent, "TOPIC", 1, 2)
+       , secretmode(parent, "secret")
+       , topiclockmode(parent, "topiclock")
 {
-       ChanModeReference secretmode;
-       ChanModeReference topiclockmode;
-
- public:
-       /** Constructor for topic.
-        */
-       CommandTopic(Module* parent)
-               : SplitCommand(parent, "TOPIC", 1, 2)
-               , secretmode(parent, "secret")
-               , topiclockmode(parent, "topiclock")
-       {
-               syntax = "<channel> [<topic>]";
-               Penalty = 2;
-       }
-
-       /** Handle command.
-        * @param parameters The parameters to the command
-        * @param user The user issuing the command
-        * @return A value from CmdResult to indicate command success or failure.
-        */
-       CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* user);
-};
+       syntax = "<channel> [<topic>]";
+       Penalty = 2;
+}
 
 CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters, LocalUser* user)
 {
@@ -68,8 +51,7 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters,
 
                if (c->topic.length())
                {
-                       user->WriteNumeric(RPL_TOPIC, "%s :%s", c->name.c_str(), c->topic.c_str());
-                       user->WriteNumeric(RPL_TOPICTIME, "%s %s %lu", c->name.c_str(), c->setby.c_str(), (unsigned long)c->topicset);
+                       Topic::ShowTopic(user, c);
                }
                else
                {
@@ -102,5 +84,8 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters,
        return CMD_SUCCESS;
 }
 
-
-COMMAND_INIT(CommandTopic)
+void Topic::ShowTopic(LocalUser* user, Channel* chan)
+{
+       user->WriteNumeric(RPL_TOPIC, "%s :%s", chan->name.c_str(), chan->topic.c_str());
+       user->WriteNumeric(RPL_TOPICTIME, "%s %s %lu", chan->name.c_str(), chan->setby.c_str(), (unsigned long)chan->topicset);
+}