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"
25 extern ServerConfig* Config;
28 extern ModuleList modules;
29 extern FactoryList factory;
31 void cmd_topic::Handle (char **parameters, int pcnt, userrec *user)
37 Ptr = FindChan(parameters[0]);
40 if ((Ptr->modes[CM_SECRET]) && (!Ptr->HasUser(user)))
42 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, Ptr->name);
47 WriteServ(user->fd,"332 %s %s :%s", user->nick, Ptr->name, Ptr->topic);
48 WriteServ(user->fd,"333 %s %s %s %d", user->nick, Ptr->name, Ptr->setby, Ptr->topicset);
52 WriteServ(user->fd,"331 %s %s :No topic is set.", user->nick, Ptr->name);
57 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
63 Ptr = FindChan(parameters[0]);
68 if (!Ptr->HasUser(user))
70 WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, Ptr->name);
73 if ((Ptr->modes[CM_TOPICLOCK]) && (cstatus(user,Ptr)<STATUS_HOP))
75 WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel", user->nick, Ptr->name);
80 strlcpy(topic,parameters[1],MAXTOPIC-1);
85 FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(user,Ptr,topic));
90 strlcpy(Ptr->topic,topic,MAXTOPIC-1);
91 strlcpy(Ptr->setby,user->nick,NICKMAX-1);
93 WriteChannel(Ptr,user,"TOPIC %s :%s",Ptr->name, Ptr->topic);
96 FOREACH_MOD(I_OnPostLocalTopicChange,OnPostLocalTopicChange(user,Ptr,topic));
101 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);