2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2019 linuxdaemon <linuxdaemon.irc@gmail.com>
5 * Copyright (C) 2018 Sadie Powell <sadie@witchery.services>
7 * This file is part of InspIRCd. InspIRCd is free software: you can
8 * redistribute it and/or modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation, version 2.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 class Who::EventListener : public Events::ModuleEventListener
34 EventListener(Module* mod)
35 : ModuleEventListener(mod, "event/who")
39 /** Called when a result from WHO is about to be queued.
40 * @param request Details about the WHO request which caused this response.
41 * @param source The user who initiated this WHO request.
42 * @param user The user that this line of the WHO request is about.
43 * @param memb The channel membership of the user or NULL if not targeted at a channel.
44 * @param numeric The numeric which will be sent in response to the request.
45 * @return MOD_RES_ALLOW to explicitly allow the response, MOD_RES_DENY to explicitly deny the
46 * response, or MOD_RES_PASSTHRU to let another module handle the event.
48 virtual ModResult OnWhoLine(const Request& request, LocalUser* source, User* user, Membership* memb, Numeric::Numeric& numeric) = 0;
54 /** The flags for matching users to include. */
55 std::bitset<UCHAR_MAX> flags;
57 /** Whether we are matching using a wildcard or a flag. */
60 /** The text to match against. */
61 std::string matchtext;
63 /** The WHO/WHOX responses we will send to the source. */
64 std::vector<Numeric::Numeric> results;
66 /** Whether the source requested a WHOX response. */
69 /** The fields to include in the WHOX response. */
70 std::bitset<UCHAR_MAX> whox_fields;
72 /** A user specified label for the WHOX response. */
73 std::string whox_querytype;
75 /** Get the index in the response parameters for the different data fields
77 * The fields 'r' (realname) and 'd' (hops) will always be missing in a non-WHOX
78 * query, because WHOX splits them to 2 fields, where old WHO has them as one.
80 * @param flag The field name to look for
81 * @param out The index will be stored in this value
82 * @return True if the field is available, false otherwise
84 virtual bool GetFieldIndex(char flag, size_t& out) const = 0;