2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2018 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2016 Attila Molnar <attilamolnar@hush.com>
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/>.
32 class Stats::EventListener : public Events::ModuleEventListener
35 EventListener(Module* mod)
36 : ModuleEventListener(mod, "event/stats")
40 /** Called when the STATS command is executed.
41 * @param stats Context of the /STATS request, contains requesting user, list of answer rows etc.
42 * @return MOD_RES_DENY if the stats request has been fulfilled. Otherwise, MOD_RES_PASSTHRU.
44 virtual ModResult OnStats(Stats::Context& stats) = 0;
47 class Stats::Row : public Numeric::Numeric
58 /** Source user of the STATS request
62 /** List of reply rows
64 std::vector<Row> rows;
66 /** Symbol indicating the type of this STATS request (usually a letter)
72 * @param src Source user of the STATS request, can be a local or remote user
73 * @param sym Symbol (letter) indicating the type of the request
75 Context(User* src, char sym)
81 /** Get the source user of the STATS request
82 * @return Source user of the STATS request
84 User* GetSource() const { return source; }
86 /** Get the list of reply rows
87 * @return List of rows generated as reply for the request
89 const std::vector<Row>& GetRows() const { return rows; }
91 /** Get the symbol (letter) indicating what type of STATS was requested
92 * @return Symbol specified by the requesting user
94 char GetSymbol() const { return symbol; }
96 /** Add a row to the reply list
97 * @param row Reply to add
99 void AddRow(const Row& row) { rows.push_back(row); }
101 template <typename T1>
102 void AddRow(unsigned int numeric, T1 p1)
109 template <typename T1, typename T2>
110 void AddRow(unsigned int numeric, T1 p1, T2 p2)
118 template <typename T1, typename T2, typename T3>
119 void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3)
128 template <typename T1, typename T2, typename T3, typename T4>
129 void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4)
139 template <typename T1, typename T2, typename T3, typename T4, typename T5>
140 void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5)
151 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
152 void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6)
164 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
165 void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7)
178 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
179 void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7, T8 p8)