2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 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/>.
31 class Stats::EventListener : public Events::ModuleEventListener
34 EventListener(Module* mod)
35 : ModuleEventListener(mod, "event/stats")
39 /** Called when the STATS command is executed.
40 * @param stats Context of the /STATS request, contains requesting user, list of answer rows etc.
41 * @return MOD_RES_DENY if the stats request has been fulfilled. Otherwise, MOD_RES_PASSTHRU.
43 virtual ModResult OnStats(Stats::Context& stats) = 0;
46 class Stats::Row : public Numeric::Numeric
57 /** Source user of the STATS request
61 /** List of reply rows
63 std::vector<Row> rows;
65 /** Symbol indicating the type of this STATS request (usually a letter)
71 * @param src Source user of the STATS request, can be a local or remote user
72 * @param sym Symbol (letter) indicating the type of the request
74 Context(User* src, char sym)
80 /** Get the source user of the STATS request
81 * @return Source user of the STATS request
83 User* GetSource() const { return source; }
85 /** Get the list of reply rows
86 * @return List of rows generated as reply for the request
88 const std::vector<Row>& GetRows() const { return rows; }
90 /** Get the symbol (letter) indicating what type of STATS was requested
91 * @return Symbol specified by the requesting user
93 char GetSymbol() const { return symbol; }
95 /** Add a row to the reply list
96 * @param row Reply to add
98 void AddRow(const Row& row) { rows.push_back(row); }
100 template <typename T1>
101 void AddRow(unsigned int numeric, T1 p1)
108 template <typename T1, typename T2>
109 void AddRow(unsigned int numeric, T1 p1, T2 p2)
117 template <typename T1, typename T2, typename T3>
118 void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3)
127 template <typename T1, typename T2, typename T3, typename T4>
128 void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4)
138 template <typename T1, typename T2, typename T3, typename T4, typename T5>
139 void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5)
150 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
151 void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6)
163 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
164 void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7)
177 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
178 void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7, T8 p8)