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