1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
17 #include "inspircd_config.h"
18 #include "configreader.h"
22 #include "commands/cmd_topic.h"
25 void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
31 Ptr = ServerInstance->FindChan(parameters[0]);
34 if ((Ptr->modes[CM_SECRET]) && (!Ptr->HasUser(user)))
36 user->WriteServ("401 %s %s :No such nick/channel",user->nick, Ptr->name);
41 user->WriteServ("332 %s %s :%s", user->nick, Ptr->name, Ptr->topic);
42 user->WriteServ("333 %s %s %s %d", user->nick, Ptr->name, Ptr->setby, Ptr->topicset);
46 user->WriteServ("331 %s %s :No topic is set.", user->nick, Ptr->name);
51 user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]);
57 Ptr = ServerInstance->FindChan(parameters[0]);
62 if (!Ptr->HasUser(user))
64 user->WriteServ("442 %s %s :You're not on that channel!",user->nick, Ptr->name);
67 if ((Ptr->modes[CM_TOPICLOCK]) && (Ptr->GetStatus(user) < STATUS_HOP))
69 user->WriteServ("482 %s %s :You must be at least a half-operator to change modes on this channel", user->nick, Ptr->name);
74 strlcpy(topic,parameters[1],MAXTOPIC-1);
79 FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(user,Ptr,topic));
84 strlcpy(Ptr->topic,topic,MAXTOPIC-1);
85 strlcpy(Ptr->setby,user->nick,NICKMAX-1);
86 Ptr->topicset = ServerInstance->Time();
87 Ptr->WriteChannel(user, "TOPIC %s :%s", Ptr->name, Ptr->topic);
90 FOREACH_MOD(I_OnPostLocalTopicChange,OnPostLocalTopicChange(user,Ptr,topic));
95 user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]);