- /* Implement the part of cmd_privmsg.cpp that handles *channel* messages, if cmd_privmsg.cpp
- * is changed this probably needs updating too. Also implement the actual write to the users
- * on the channel. This code is from channels.cpp, and should also be changed if channels.cpp
- * updates it's corresponding code
- */
- if ((validated) && (command == "PRIVMSG"))
- {
- char status = 0;
- if ((*parameters[0] == '@') || (*parameters[0] == '%') || (*parameters[0] == '+'))
- {
- status = *parameters[0];
- parameters[0]++;
- }
- if (parameters[0][0] == '#')
- {
- chanrec *chan;
- user->idle_lastmsg = ServerInstance->Time();
- chan = ServerInstance->FindChan(parameters[0]);
- if (chan)
- {
- if (IS_LOCAL(user))
- {
- if ((chan->modes[CM_NOEXTERNAL]) && (!chan->HasUser(user)))
- {
- user->WriteServ("404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name);
- return 1;
- }
- if ((chan->modes[CM_MODERATED]) && (chan->GetStatus(user) < STATUS_VOICE))
- {
- user->WriteServ("404 %s %s :Cannot send to channel (+m)", user->nick, chan->name);
- return 1;
- }
- }
- int MOD_RESULT = 0;
-
- std::string temp = parameters[1];
- FOREACH_RESULT(I_OnUserPreMessage,OnUserPreMessage(user,chan,TYPE_CHANNEL,temp,status));
- if (MOD_RESULT) {
- return 1;
- }
- parameters[1] = temp.c_str();
-
- if (temp == "")
- {
- user->WriteServ("412 %s No text to send", user->nick);
- return 1;
- }
-
- /* This next call into channel.cpp is the one that gets replaced by our modified method
- * chan->WriteAllExceptSender(user, false, status, "PRIVMSG %s :%s", chan->name, parameters[1]);
- */
- WriteAllExceptSenderAndSilenced(chan, user, false, status, "PRIVMSG %s :%s", chan->name, parameters[1]);