2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2018 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2013-2014, 2016 Attila Molnar <attilamolnar@hush.com>
6 * Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
7 * Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
8 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
9 * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
10 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
11 * Copyright (C) 2006, 2008, 2010 Craig Edwards <brain@inspircd.org>
13 * This file is part of InspIRCd. InspIRCd is free software: you can
14 * redistribute it and/or modify it under the terms of the GNU General Public
15 * License as published by the Free Software Foundation, version 2.
17 * This program is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #include "core_user.h"
37 CommandAway::CommandAway(Module* parent)
38 : Command(parent, "AWAY", 0, 1)
41 allow_empty_last_param = false;
42 syntax = "[:<message>]";
47 CmdResult CommandAway::Handle(User* user, const Params& parameters)
49 LocalUser* luser = IS_LOCAL(user);
52 if (!parameters.empty())
54 std::string message(parameters[0]);
57 FIRST_MOD_RESULT_CUSTOM(awayevprov, Away::EventListener, OnUserPreAway, MOD_RESULT, (luser, message));
58 if (MOD_RESULT == MOD_RES_DENY)
62 user->awaytime = ServerInstance->Time();
63 user->awaymsg.assign(message, 0, ServerInstance->Config->Limits.MaxAway);
64 user->WriteNumeric(RPL_NOWAWAY, "You have been marked as being away");
65 FOREACH_MOD_CUSTOM(awayevprov, Away::EventListener, OnUserAway, (user));
71 FIRST_MOD_RESULT_CUSTOM(awayevprov, Away::EventListener, OnUserPreBack, MOD_RESULT, (luser));
72 if (MOD_RESULT == MOD_RES_DENY)
77 user->awaymsg.clear();
78 user->WriteNumeric(RPL_UNAWAY, "You are no longer marked as being away");
79 FOREACH_MOD_CUSTOM(awayevprov, Away::EventListener, OnUserBack, (user));
85 RouteDescriptor CommandAway::GetRouting(User* user, const Params& parameters)
87 return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST);