X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcommands%2Fcmd_away.cpp;h=7fac7ae6d382792f05e9e07b3e8846924ae40fc7;hb=4b856bda135a08e800b96c970a10b0b6a34d433a;hp=ce4628858043f5eebb4c11b128ce779d587feaea;hpb=5d5285f24b1fe306faa2a6d0565ba1cff0f17f11;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/commands/cmd_away.cpp b/src/commands/cmd_away.cpp index ce4628858..7fac7ae6d 100644 --- a/src/commands/cmd_away.cpp +++ b/src/commands/cmd_away.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 @@ -21,19 +21,32 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance) /** Handle /AWAY */ -CmdResult CommandAway::Handle (const char** parameters, int pcnt, User *user) +CmdResult CommandAway::Handle (const std::vector& parameters, User *user) { - if ((pcnt) && (*parameters[0])) + int MOD_RESULT = 0; + + if ((parameters.size()) && (!parameters[0].empty())) { - strlcpy(user->awaymsg,parameters[0],MAXAWAY); - user->WriteServ("306 %s :You have been marked as being away",user->nick); - FOREACH_MOD(I_OnSetAway,OnSetAway(user)); + FOREACH_RESULT(I_OnSetAway, OnSetAway(user, parameters[0])); + + if (MOD_RESULT != 0 && !IS_LOCAL(user)) + return CMD_FAILURE; + + user->awaytime = ServerInstance->Time(); + user->awaymsg.assign(parameters[0], 0, MAXAWAY); + + user->WriteNumeric(306, "%s :You have been marked as being away",user->nick.c_str()); } else { - *user->awaymsg = 0; - user->WriteServ("305 %s :You are no longer marked as being away",user->nick); - FOREACH_MOD(I_OnCancelAway,OnCancelAway(user)); + FOREACH_RESULT(I_OnSetAway, OnSetAway(user, "")); + + if (MOD_RESULT != 0 && !IS_LOCAL(user)) + return CMD_FAILURE; + + user->awaymsg.empty(); + user->WriteNumeric(305, "%s :You are no longer marked as being away",user->nick.c_str()); } + return CMD_SUCCESS; }