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))))
51 std::string temp = parameters[1];
52 FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,(void*)parameters[0],TYPE_SERVER,temp,0));
55 parameters[1] = (char*)temp.c_str();
56 // notice to server mask
57 const char* servermask = parameters[0] + 1;
58 if (match(Config->ServerName,servermask))
60 NoticeAll(user, true, "%s",parameters[1]);
62 FOREACH_MOD(I_OnUserMessage,OnUserNotice(user,(void*)parameters[0],TYPE_SERVER,parameters[1],0));
66 if ((*parameters[0] == '@') || (*parameters[0] == '%') || (*parameters[0] == '+'))
68 status = *parameters[0];
71 if (*parameters[0] == '#')
73 chan = FindChan(parameters[0]);
78 if ((chan->modes[CM_NOEXTERNAL]) && (!chan->HasUser(user)))
80 WriteServ(user->fd,"404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name);
83 if ((chan->modes[CM_MODERATED]) && (cstatus(user,chan)<STATUS_VOICE))
85 WriteServ(user->fd,"404 %s %s :Cannot send to channel (+m)", user->nick, chan->name);
92 std::string temp = parameters[1];
93 FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,chan,TYPE_CHANNEL,temp,status));
97 parameters[1] = (char*)temp.c_str();
101 WriteServ(user->fd,"412 %s No text to send", user->nick);
105 ChanExceptSender(chan, user, status, "NOTICE %s :%s", chan->name, parameters[1]);
107 FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,chan,TYPE_CHANNEL,parameters[1],status));
111 /* no such nick/channel */
112 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
117 dest = Find(parameters[0]);
122 std::string temp = parameters[1];
123 FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,dest,TYPE_USER,temp,0));
127 parameters[1] = (char*)temp.c_str();
131 // direct write, same server
132 WriteTo(user, dest, "NOTICE %s :%s", dest->nick, parameters[1]);
135 FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,dest,TYPE_USER,parameters[1],0));
139 /* no such nick/channel */
140 WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);