X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcommands%2Fcmd_notice.cpp;h=ee9868fb3f9a13b2ad21d3da60a93727ba8f3afb;hb=3f971b447fae258a92f2cc6645497cce93f1c04e;hp=ca693d62b390acc4d23c682e76e22c55221657ac;hpb=be1286835c016ed2602db8e42f7ca0b367767242;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/commands/cmd_notice.cpp b/src/commands/cmd_notice.cpp index ca693d62b..ee9868fb3 100644 --- a/src/commands/cmd_notice.cpp +++ b/src/commands/cmd_notice.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * InspIRCd: (C) 2002-2008 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see @@ -20,7 +20,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance) return new CommandNotice(Instance); } -CmdResult CommandNotice::Handle (const char** parameters, int pcnt, User *user) +CmdResult CommandNotice::Handle (const char* const* parameters, int pcnt, User *user) { User *dest; Channel *chan; @@ -38,26 +38,27 @@ CmdResult CommandNotice::Handle (const char** parameters, int pcnt, User *user) FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,(void*)parameters[0],TYPE_SERVER,temp,0,exempt_list)); if (MOD_RESULT) return CMD_FAILURE; - parameters[1] = temp.c_str(); - // notice to server mask + const char* text = temp.c_str(); const char* servermask = parameters[0] + 1; - FOREACH_MOD(I_OnText,OnText(user,(void*)parameters[0],TYPE_SERVER,parameters[1],0,exempt_list)); + + FOREACH_MOD(I_OnText,OnText(user,(void*)parameters[0],TYPE_SERVER,text,0,exempt_list)); if (match(ServerInstance->Config->ServerName,servermask)) { - user->SendAll("NOTICE", "%s", parameters[1]); + user->SendAll("NOTICE", "%s", text); } - FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,(void*)parameters[0],TYPE_SERVER,parameters[1],0,exempt_list)); + FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,(void*)parameters[0],TYPE_SERVER,text,0,exempt_list)); return CMD_SUCCESS; } char status = 0; - if ((*parameters[0] == '@') || (*parameters[0] == '%') || (*parameters[0] == '+')) + const char* target = parameters[0]; + if ((*target == '@') || (*target == '%') || (*target == '+')) { - status = *parameters[0]; - parameters[0]++; + status = *target; + target++; } - if (*parameters[0] == '#') + if (*target == '#') { - chan = ServerInstance->FindChan(parameters[0]); + chan = ServerInstance->FindChan(target); exempt_list[user] = user->nick; @@ -67,12 +68,12 @@ CmdResult CommandNotice::Handle (const char** parameters, int pcnt, User *user) { if ((chan->IsModeSet('n')) && (!chan->HasUser(user))) { - user->WriteServ("404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name); + user->WriteNumeric(404, "%s %s :Cannot send to channel (no external messages)", user->nick, chan->name); return CMD_FAILURE; } if ((chan->IsModeSet('m')) && (chan->GetStatus(user) < STATUS_VOICE)) { - user->WriteServ("404 %s %s :Cannot send to channel (+m)", user->nick, chan->name); + user->WriteNumeric(404, "%s %s :Cannot send to channel (+m)", user->nick, chan->name); return CMD_FAILURE; } } @@ -83,38 +84,38 @@ CmdResult CommandNotice::Handle (const char** parameters, int pcnt, User *user) if (MOD_RESULT) { return CMD_FAILURE; } - parameters[1] = temp.c_str(); + const char* text = temp.c_str(); if (temp.empty()) { - user->WriteServ("412 %s :No text to send", user->nick); + user->WriteNumeric(412, "%s :No text to send", user->nick); return CMD_FAILURE; } - FOREACH_MOD(I_OnText,OnText(user,chan,TYPE_CHANNEL,parameters[1],status,exempt_list)); + FOREACH_MOD(I_OnText,OnText(user,chan,TYPE_CHANNEL,text,status,exempt_list)); if (status) { if (ServerInstance->Config->UndernetMsgPrefix) { - chan->WriteAllExcept(user, false, status, exempt_list, "NOTICE %c%s :%c %s", status, chan->name, status, parameters[1]); + chan->WriteAllExcept(user, false, status, exempt_list, "NOTICE %c%s :%c %s", status, chan->name, status, text); } else { - chan->WriteAllExcept(user, false, status, exempt_list, "NOTICE %c%s :%s", status, chan->name, parameters[1]); + chan->WriteAllExcept(user, false, status, exempt_list, "NOTICE %c%s :%s", status, chan->name, text); } } else { - chan->WriteAllExcept(user, false, status, exempt_list, "NOTICE %s :%s", chan->name, parameters[1]); + chan->WriteAllExcept(user, false, status, exempt_list, "NOTICE %s :%s", chan->name, text); } - FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,chan,TYPE_CHANNEL,parameters[1],status,exempt_list)); + FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,chan,TYPE_CHANNEL,text,status,exempt_list)); } else { /* no such nick/channel */ - user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, target); return CMD_FAILURE; } return CMD_SUCCESS; @@ -134,7 +135,7 @@ CmdResult CommandNotice::Handle (const char** parameters, int pcnt, User *user) if (dest && strcasecmp(dest->server, targetserver + 1)) { /* Incorrect server for user */ - user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0]); return CMD_FAILURE; } } @@ -148,7 +149,7 @@ CmdResult CommandNotice::Handle (const char** parameters, int pcnt, User *user) { if (!*parameters[1]) { - user->WriteServ("412 %s :No text to send", user->nick); + user->WriteNumeric(412, "%s :No text to send", user->nick); return CMD_FAILURE; } @@ -158,22 +159,22 @@ CmdResult CommandNotice::Handle (const char** parameters, int pcnt, User *user) if (MOD_RESULT) { return CMD_FAILURE; } - parameters[1] = (char*)temp.c_str(); + const char* text = temp.c_str(); - FOREACH_MOD(I_OnText,OnText(user,dest,TYPE_USER,parameters[1],0,exempt_list)); + FOREACH_MOD(I_OnText,OnText(user,dest,TYPE_USER,text,0,exempt_list)); if (IS_LOCAL(dest)) { // direct write, same server - user->WriteTo(dest, "NOTICE %s :%s", dest->nick, parameters[1]); + user->WriteTo(dest, "NOTICE %s :%s", dest->nick, text); } - FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,dest,TYPE_USER,parameters[1],0,exempt_list)); + FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,dest,TYPE_USER,text,0,exempt_list)); } else { /* no such nick/channel */ - user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0]); return CMD_FAILURE; }