X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Fftopic.cpp;h=d559c6ae5c642bb3ba8f23bd9f03c489a390f443;hb=ccd4c11ea1a43d079eaae9708482ef4a9148796c;hp=3ea77511242a7dc9376c138849c01c13e1607a40;hpb=31f1e7ad092f8bf16ee653cc105eea4a769650ca;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/ftopic.cpp b/src/modules/m_spanningtree/ftopic.cpp index 3ea775112..d559c6ae5 100644 --- a/src/modules/m_spanningtree/ftopic.cpp +++ b/src/modules/m_spanningtree/ftopic.cpp @@ -1,70 +1,51 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2008 InspIRCd Development Team - * See: http://www.inspircd.org/wiki/index.php/Credits + * Copyright (C) 2010 Daniel De Graaf + * Copyright (C) 2008 Robin Burchell * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#include "inspircd.h" -#include "xline.h" - -#include "m_spanningtree/treesocket.h" -#include "m_spanningtree/treeserver.h" -#include "m_spanningtree/utils.h" -/* $ModDep: m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */ +#include "inspircd.h" +#include "commands.h" +#include "treesocket.h" +#include "treeserver.h" +#include "utils.h" /** FTOPIC command */ -bool TreeSocket::ForceTopic(const std::string &source, std::deque ¶ms) +CmdResult CommandFTopic::Handle(const std::vector& params, User *user) { - if (params.size() != 4) - return true; time_t ts = atoi(params[1].c_str()); - std::string nsource = source; - Channel* c = this->Instance->FindChan(params[0]); + Channel* c = ServerInstance->FindChan(params[0]); if (c) { if ((ts >= c->topicset) || (c->topic.empty())) { - std::string oldtopic = c->topic; - c->topic.assign(params[3], 0, MAXTOPIC); - c->setby.assign(params[2], 0, 127); - c->topicset = ts; - /* if the topic text is the same as the current topic, - * dont bother to send the TOPIC command out, just silently - * update the set time and set nick. - */ - if (oldtopic != params[3]) + if (c->topic != params[3]) { - User* user = this->Instance->FindNick(source); - if (!user) - { - c->WriteChannelWithServ(Instance->Config->ServerName, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str()); - } - else - { - c->WriteChannel(user, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str()); - nsource = user->server; - } + // Update topic only when it differs from current topic + c->topic.assign(params[3], 0, ServerInstance->Config->Limits.MaxTopic); + c->WriteChannel(user, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str()); } - /* all done, send it on its way */ - params[3] = ":" + params[3]; - User* u = Instance->FindNick(nsource); - if (u) - Utils->DoOneToAllButSender(u->uuid,"FTOPIC",params,u->server); - else - Utils->DoOneToAllButSender(source,"FTOPIC",params,nsource); + // Always update setter and settime. + c->setby.assign(params[2], 0, 127); + c->topicset = ts; } - } - return true; + return CMD_SUCCESS; }