X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcmd_privmsg.cpp;h=96aff839246ae6c00a621ea031e0a6401391fec8;hb=4cc6e5e14fdbde499481dbab5ab2ad1257b8af9c;hp=1614a62dcf454062a74573732a3008488c8104b5;hpb=e6fa614ad27cd68aa61605ca0884eee9c44384eb;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp index 1614a62dc..96aff8392 100644 --- a/src/cmd_privmsg.cpp +++ b/src/cmd_privmsg.cpp @@ -12,24 +12,18 @@ */ #include "inspircd.h" -#include "configreader.h" -#include "users.h" -#include "modules.h" #include "wildcard.h" #include "commands/cmd_privmsg.h" - - -extern "C" command_t* init_command(InspIRCd* Instance) +extern "C" DllExport Command* init_command(InspIRCd* Instance) { - return new cmd_privmsg(Instance); + return new CommandPrivmsg(Instance); } -CmdResult cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult CommandPrivmsg::Handle (const char** parameters, int pcnt, User *user) { - userrec *dest; - chanrec *chan; - + User *dest; + Channel *chan; CUList except_list; user->idle_lastmsg = ServerInstance->Time(); @@ -70,12 +64,12 @@ CmdResult cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user) { if (IS_LOCAL(user)) { - if ((chan->modes[CM_NOEXTERNAL]) && (!chan->HasUser(user))) + if ((chan->IsModeSet('n')) && (!chan->HasUser(user))) { user->WriteServ("404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name); return CMD_FAILURE; } - if ((chan->modes[CM_MODERATED]) && (chan->GetStatus(user) < STATUS_VOICE)) + if ((chan->IsModeSet('m')) && (chan->GetStatus(user) < STATUS_VOICE)) { user->WriteServ("404 %s %s :Cannot send to channel (+m)", user->nick, chan->name); return CMD_FAILURE; @@ -90,9 +84,10 @@ CmdResult cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user) } parameters[1] = temp.c_str(); + /* Check again, a module may have zapped the input string */ if (temp.empty()) { - user->WriteServ("412 %s No text to send", user->nick); + user->WriteServ("412 %s :No text to send", user->nick); return CMD_FAILURE; } @@ -123,10 +118,20 @@ CmdResult cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user) return CMD_SUCCESS; } - dest = ServerInstance->FindNick(parameters[0]); + if (IS_LOCAL(user)) + dest = ServerInstance->FindNickOnly(parameters[0]); + else + dest = ServerInstance->FindNick(parameters[0]); + if (dest) { - if ((IS_LOCAL(user)) && (*dest->awaymsg)) + if (!*parameters[1]) + { + user->WriteServ("412 %s :No text to send", user->nick); + return CMD_FAILURE; + } + + if (IS_AWAY(dest)) { /* auto respond with aweh msg */ user->WriteServ("301 %s %s :%s",user->nick,dest->nick,dest->awaymsg);