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"
23 #include "commands/cmd_topic.h"
24 #include "helperfuncs.h"
26 extern ServerConfig* Config;
29 extern ModuleList modules;
30 extern FactoryList factory;
32 void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
38 Ptr = FindChan(parameters[0]);
41 if ((Ptr->modes[CM_SECRET]) && (!Ptr->HasUser(user)))
43 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, Ptr->name);
48 WriteServ(user->fd,"332 %s %s :%s", user->nick, Ptr->name, Ptr->topic);
49 WriteServ(user->fd,"333 %s %s %s %d", user->nick, Ptr->name, Ptr->setby, Ptr->topicset);
53 WriteServ(user->fd,"331 %s %s :No topic is set.", user->nick, Ptr->name);
58 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
64 Ptr = FindChan(parameters[0]);
69 if (!Ptr->HasUser(user))
71 WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, Ptr->name);
74 if ((Ptr->modes[CM_TOPICLOCK]) && (cstatus(user,Ptr)<STATUS_HOP))
76 WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel", user->nick, Ptr->name);
81 strlcpy(topic,parameters[1],MAXTOPIC-1);
86 FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(user,Ptr,topic));
91 strlcpy(Ptr->topic,topic,MAXTOPIC-1);
92 strlcpy(Ptr->setby,user->nick,NICKMAX-1);
94 WriteChannel(Ptr,user,"TOPIC %s :%s",Ptr->name, Ptr->topic);
97 FOREACH_MOD(I_OnPostLocalTopicChange,OnPostLocalTopicChange(user,Ptr,topic));
102 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);