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;
35 RPL_WHOISOPERATOR = 313,
37 RPL_WHOISCHANNELS = 319,
47 class Whois::EventListener : public Events::ModuleEventListener
50 EventListener(Module* mod)
51 : ModuleEventListener(mod, "event/whois")
55 /** Called whenever a /WHOIS is performed by a local user.
56 * @param whois Whois context, can be used to send numerics
58 virtual void OnWhois(Context& whois) = 0;
61 class Whois::LineEventListener : public Events::ModuleEventListener
64 LineEventListener(Module* mod)
65 : ModuleEventListener(mod, "event/whoisline")
69 /** Called whenever a line of WHOIS output is sent to a user.
70 * You may change the numeric and the text of the output by changing
71 * the values numeric and text, but you cannot change the user the
73 * @param whois Whois context, can be used to send numerics
74 * @param numeric Numeric being sent
75 * @return MOD_RES_DENY to drop the line completely so that the user does not
76 * receive it, or MOD_RES_PASSTHRU to allow the line to be sent.
78 virtual ModResult OnWhoisLine(Context& whois, Numeric::Numeric& numeric) = 0;
84 /** User doing the WHOIS
86 LocalUser* const source;
88 /** User being WHOISed
93 Context(LocalUser* src, User* targ)
99 /** Returns true if the user is /WHOISing himself
100 * @return True if whois source is the same user as the whois target, false if they are different users
102 bool IsSelfWhois() const { return (source == target); }
104 /** Returns the LocalUser who has done the /WHOIS
105 * @return LocalUser doing the /WHOIS
107 LocalUser* GetSource() const { return source; }
109 /** Returns the target of the /WHOIS
110 * @return User who was /WHOIS'd
112 User* GetTarget() const { return target; }
114 /** Send a line of WHOIS data to the source of the WHOIS
116 template <typename T1>
117 void SendLine(unsigned int numeric, T1 p1)
119 Numeric::Numeric n(numeric);
120 n.push(target->nick);
125 template <typename T1, typename T2>
126 void SendLine(unsigned int numeric, T1 p1, T2 p2)
128 Numeric::Numeric n(numeric);
129 n.push(target->nick);
135 template <typename T1, typename T2, typename T3>
136 void SendLine(unsigned int numeric, T1 p1, T2 p2, T3 p3)
138 Numeric::Numeric n(numeric);
139 n.push(target->nick);
146 template <typename T1, typename T2, typename T3, typename T4>
147 void SendLine(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4)
149 Numeric::Numeric n(numeric);
150 n.push(target->nick);
158 /** Send a line of WHOIS data to the source of the WHOIS
159 * @param numeric Numeric to send
161 virtual void SendLine(Numeric::Numeric& numeric) = 0;