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 InspIRCd* ServerInstance;
34 extern std::vector<Module*> modules;
35 extern std::vector<ircd_module*> factory;
38 void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user)
43 user->idle_lastmsg = TIME;
45 if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
47 if ((parameters[0][0] == '$') && ((*user->oper) || (is_uline(user->server))))
50 std::string temp = parameters[1];
51 FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,(void*)parameters[0],TYPE_SERVER,temp,0));
54 parameters[1] = (char*)temp.c_str();
55 // notice to server mask
56 const char* servermask = parameters[0] + 1;
57 if (match(ServerInstance->Config->ServerName,servermask))
59 user->NoticeAll("%s",parameters[1]);
61 FOREACH_MOD(I_OnUserMessage,OnUserNotice(user,(void*)parameters[0],TYPE_SERVER,parameters[1],0));
65 if ((*parameters[0] == '@') || (*parameters[0] == '%') || (*parameters[0] == '+'))
67 status = *parameters[0];
70 if (*parameters[0] == '#')
72 chan = FindChan(parameters[0]);
77 if ((chan->modes[CM_NOEXTERNAL]) && (!chan->HasUser(user)))
79 user->WriteServ("404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name);
82 if ((chan->modes[CM_MODERATED]) && (cstatus(user,chan)<STATUS_VOICE))
84 user->WriteServ("404 %s %s :Cannot send to channel (+m)", user->nick, chan->name);
91 std::string temp = parameters[1];
92 FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,chan,TYPE_CHANNEL,temp,status));
96 parameters[1] = (char*)temp.c_str();
100 user->WriteServ("412 %s No text to send", user->nick);
104 chan->WriteAllExceptSender(user, status, "NOTICE %s :%s", chan->name, parameters[1]);
106 FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,chan,TYPE_CHANNEL,parameters[1],status));
110 /* no such nick/channel */
111 user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]);
116 dest = Find(parameters[0]);
121 std::string temp = parameters[1];
122 FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,dest,TYPE_USER,temp,0));
126 parameters[1] = (char*)temp.c_str();
130 // direct write, same server
131 user->WriteTo(dest, "NOTICE %s :%s", dest->nick, parameters[1]);
134 FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,dest,TYPE_USER,parameters[1],0));
138 /* no such nick/channel */
139 user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]);