#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)
{
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
{
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);
+}