]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/commands/cmd_away.cpp
ModResult conversion: Change return type of all module functions
[user/henk/code/inspircd.git] / src / commands / cmd_away.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "commands/cmd_away.h"
16
17 extern "C" DllExport Command* init_command(InspIRCd* Instance)
18 {
19         return new CommandAway(Instance);
20 }
21
22 /** Handle /AWAY
23  */
24 CmdResult CommandAway::Handle (const std::vector<std::string>& parameters, User *user)
25 {
26         ModResult MOD_RESULT;
27
28         if ((parameters.size()) && (!parameters[0].empty()))
29         {
30                 FIRST_MOD_RESULT(ServerInstance, OnSetAway, MOD_RESULT, (user, parameters[0]));
31
32                 if (MOD_RESULT == MOD_RES_DENY && IS_LOCAL(user))
33                         return CMD_FAILURE;
34
35                 user->awaytime = ServerInstance->Time();
36                 user->awaymsg.assign(parameters[0], 0, ServerInstance->Config->Limits.MaxAway);
37
38                 user->WriteNumeric(RPL_NOWAWAY, "%s :You have been marked as being away",user->nick.c_str());
39         }
40         else
41         {
42                 FIRST_MOD_RESULT(ServerInstance, OnSetAway, MOD_RESULT, (user, ""));
43
44                 if (MOD_RESULT == MOD_RES_DENY && IS_LOCAL(user))
45                         return CMD_FAILURE;
46
47                 user->awaymsg.clear();
48                 user->WriteNumeric(RPL_UNAWAY, "%s :You are no longer marked as being away",user->nick.c_str());
49         }
50
51         return CMD_SUCCESS;
52 }