2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2015-2016 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/>.
27 class LineEventListener;
31 class Whois::EventListener : public Events::ModuleEventListener
34 EventListener(Module* mod)
35 : ModuleEventListener(mod, "event/whois")
39 /** Called whenever a /WHOIS is performed by a local user.
40 * @param whois Whois context, can be used to send numerics
42 virtual void OnWhois(Context& whois) = 0;
45 class Whois::LineEventListener : public Events::ModuleEventListener
48 LineEventListener(Module* mod)
49 : ModuleEventListener(mod, "event/whoisline")
53 /** Called whenever a line of WHOIS output is sent to a user.
54 * You may change the numeric and the text of the output by changing
55 * the values numeric and text, but you cannot change the user the
57 * @param whois Whois context, can be used to send numerics
58 * @param numeric Numeric being sent
59 * @return MOD_RES_DENY to drop the line completely so that the user does not
60 * receive it, or MOD_RES_PASSTHRU to allow the line to be sent.
62 virtual ModResult OnWhoisLine(Context& whois, Numeric::Numeric& numeric) = 0;
68 /** User doing the WHOIS
70 LocalUser* const source;
72 /** User being WHOISed
77 Context(LocalUser* src, User* targ)
83 /** Returns true if the user is /WHOISing himself
84 * @return True if whois source is the same user as the whois target, false if they are different users
86 bool IsSelfWhois() const { return (source == target); }
88 /** Returns the LocalUser who has done the /WHOIS
89 * @return LocalUser doing the /WHOIS
91 LocalUser* GetSource() const { return source; }
93 /** Returns the target of the /WHOIS
94 * @return User who was /WHOIS'd
96 User* GetTarget() const { return target; }
98 /** Send a line of WHOIS data to the source of the WHOIS
100 template <typename T1>
101 void SendLine(unsigned int numeric, T1 p1)
103 Numeric::Numeric n(numeric);
104 n.push(target->nick);
109 template <typename T1, typename T2>
110 void SendLine(unsigned int numeric, T1 p1, T2 p2)
112 Numeric::Numeric n(numeric);
113 n.push(target->nick);
119 template <typename T1, typename T2, typename T3>
120 void SendLine(unsigned int numeric, T1 p1, T2 p2, T3 p3)
122 Numeric::Numeric n(numeric);
123 n.push(target->nick);
130 template <typename T1, typename T2, typename T3, typename T4>
131 void SendLine(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4)
133 Numeric::Numeric n(numeric);
134 n.push(target->nick);
142 /** Send a line of WHOIS data to the source of the WHOIS
143 * @param numeric Numeric to send
145 virtual void SendLine(Numeric::Numeric& numeric) = 0;