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 * ---------------------------------------------------
21 #include "configreader.h"
28 #include "helperfuncs.h"
30 #include "commands/cmd_notice.h"
32 extern ServerConfig* Config;
33 extern InspIRCd* ServerInstance;
35 extern std::vector<Module*> modules;
36 extern std::vector<ircd_module*> factory;
39 void cmd_notice::Handle (char **parameters, int pcnt, userrec *user)
44 user->idle_lastmsg = TIME;
46 if (ServerInstance->Parser->LoopCall(this,parameters,pcnt,user,0,pcnt-2,0))
48 if ((parameters[0][0] == '$') && ((*user->oper) || (is_uline(user->server))))
50 // notice to server mask
51 char* servermask = parameters[0];
53 if (match(Config->ServerName,servermask))
55 NoticeAll(user, true, "%s",parameters[1]);
60 if ((*parameters[0] == '@') || (*parameters[0] == '%') || (*parameters[0] == '+'))
62 status = *parameters[0];
65 if (*parameters[0] == '#')
67 chan = FindChan(parameters[0]);
72 if ((chan->modes[CM_NOEXTERNAL]) && (!chan->HasUser(user)))
74 WriteServ(user->fd,"404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name);
77 if ((chan->modes[CM_MODERATED]) && (cstatus(user,chan)<STATUS_VOICE))
79 WriteServ(user->fd,"404 %s %s :Cannot send to channel (+m)", user->nick, chan->name);
86 std::string temp = parameters[1];
87 FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,chan,TYPE_CHANNEL,temp,status));
91 parameters[1] = (char*)temp.c_str();
95 WriteServ(user->fd,"412 %s No text to send", user->nick);
99 ChanExceptSender(chan, user, status, "NOTICE %s :%s", chan->name, parameters[1]);
101 FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,chan,TYPE_CHANNEL,parameters[1],status));
105 /* no such nick/channel */
106 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
111 dest = Find(parameters[0]);
116 std::string temp = parameters[1];
117 FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,dest,TYPE_USER,temp,0));
121 parameters[1] = (char*)temp.c_str();
125 // direct write, same server
126 WriteTo(user, dest, "NOTICE %s :%s", dest->nick, parameters[1]);
129 FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,dest,TYPE_USER,parameters[1],0));
133 /* no such nick/channel */
134 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);