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 * ---------------------------------------------------
19 #include "inspircd_config.h"
21 #include "inspircd_io.h"
25 #include <ext/hash_map>
43 #include "inspstring.h"
45 #include "helperfuncs.h"
47 #include "socketengine.h"
49 #include "command_parse.h"
50 #include "cmd_topic.h"
52 extern ServerConfig* Config;
53 extern InspIRCd* ServerInstance;
55 extern std::vector<Module*> modules;
56 extern std::vector<ircd_module*> factory;
58 extern user_hash clientlist;
59 extern chan_hash chanlist;
60 extern std::vector<userrec*> all_opers;
61 extern std::vector<userrec*> local_users;
62 extern userrec* fd_ref_table[MAX_DESCRIPTORS];
64 void cmd_topic::Handle (char **parameters, int pcnt, userrec *user)
70 Ptr = FindChan(parameters[0]);
73 if ((Ptr->binarymodes & CM_SECRET) && (!Ptr->HasUser(user)))
75 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, Ptr->name);
80 WriteServ(user->fd,"332 %s %s :%s", user->nick, Ptr->name, Ptr->topic);
81 WriteServ(user->fd,"333 %s %s %s %d", user->nick, Ptr->name, Ptr->setby, Ptr->topicset);
85 WriteServ(user->fd,"331 %s %s :No topic is set.", user->nick, Ptr->name);
90 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
96 Ptr = FindChan(parameters[0]);
101 if (!Ptr->HasUser(user))
103 WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, Ptr->name);
106 if ((Ptr->binarymodes & CM_TOPICLOCK) && (cstatus(user,Ptr)<STATUS_HOP))
108 WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel", user->nick, Ptr->name);
112 char topic[MAXTOPIC];
113 strlcpy(topic,parameters[1],MAXTOPIC-1);
118 FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(user,Ptr,topic));
123 strlcpy(Ptr->topic,topic,MAXTOPIC-1);
124 strlcpy(Ptr->setby,user->nick,NICKMAX-1);
125 Ptr->topicset = TIME;
126 WriteChannel(Ptr,user,"TOPIC %s :%s",Ptr->name, Ptr->topic);
129 FOREACH_MOD(I_OnPostLocalTopicChange,OnPostLocalTopicChange(user,Ptr,topic));
134 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);