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 (const char** parameters, int pcnt, userrec *user)
44 user->idle_lastmsg = TIME;
46 if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
48 if ((parameters[0][0] == '$') && ((*user->oper) || (is_uline(user->server))))
50 // notice to server mask
51 const char* servermask = parameters[0] + 1;
52 if (match(Config->ServerName,servermask))
54 NoticeAll(user, true, "%s",parameters[1]);
59 if ((*parameters[0] == '@') || (*parameters[0] == '%') || (*parameters[0] == '+'))
61 status = *parameters[0];
64 if (*parameters[0] == '#')
66 chan = FindChan(parameters[0]);
71 if ((chan->modes[CM_NOEXTERNAL]) && (!chan->HasUser(user)))
73 WriteServ(user->fd,"404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name);
76 if ((chan->modes[CM_MODERATED]) && (cstatus(user,chan)<STATUS_VOICE))
78 WriteServ(user->fd,"404 %s %s :Cannot send to channel (+m)", user->nick, chan->name);
85 std::string temp = parameters[1];
86 FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,chan,TYPE_CHANNEL,temp,status));
90 parameters[1] = (char*)temp.c_str();
94 WriteServ(user->fd,"412 %s No text to send", user->nick);
98 ChanExceptSender(chan, user, status, "NOTICE %s :%s", chan->name, parameters[1]);
100 FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,chan,TYPE_CHANNEL,parameters[1],status));
104 /* no such nick/channel */
105 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
110 dest = Find(parameters[0]);
115 std::string temp = parameters[1];
116 FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,dest,TYPE_USER,temp,0));
120 parameters[1] = (char*)temp.c_str();
124 // direct write, same server
125 WriteTo(user, dest, "NOTICE %s :%s", dest->nick, parameters[1]);
128 FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,dest,TYPE_USER,parameters[1],0));
132 /* no such nick/channel */
133 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);