From 9fc261d4cdfccacd53ab815539a93b23f3b75d73 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sat, 16 May 2015 16:36:12 +0200 Subject: cmd_topic Extract code sending RPL_TOPIC and RPL_TOPICTIME into a function --- src/coremods/core_channel/cmd_topic.cpp | 9 +++++++-- src/coremods/core_channel/core_channel.h | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/coremods') diff --git a/src/coremods/core_channel/cmd_topic.cpp b/src/coremods/core_channel/cmd_topic.cpp index ea723c024..8d65d764a 100644 --- a/src/coremods/core_channel/cmd_topic.cpp +++ b/src/coremods/core_channel/cmd_topic.cpp @@ -51,8 +51,7 @@ CmdResult CommandTopic::HandleLocal(const std::vector& 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 { @@ -84,3 +83,9 @@ CmdResult CommandTopic::HandleLocal(const std::vector& parameters, c->SetTopic(user, t); return CMD_SUCCESS; } + +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); +} diff --git a/src/coremods/core_channel/core_channel.h b/src/coremods/core_channel/core_channel.h index d3adbc9c9..f3efa3d67 100644 --- a/src/coremods/core_channel/core_channel.h +++ b/src/coremods/core_channel/core_channel.h @@ -21,6 +21,11 @@ #include "inspircd.h" +namespace Topic +{ + void ShowTopic(LocalUser* user, Channel* chan); +} + /** Handle /INVITE. */ class CommandInvite : public Command -- cgit v1.2.3