diff options
author | Attila Molnar <attilamolnar@hush.com> | 2016-02-25 17:02:03 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2016-02-25 17:02:03 +0100 |
commit | 304b6dbbf56710b1310fce8c5cf71b73334c060a (patch) | |
tree | 002d219057b5b4fda5c49595eada3eb7e1e8d525 /src/modules/m_spanningtree | |
parent | dbe5a1fc6f9e18765863f332a3e79d7c918d3e65 (diff) |
Introduce Stats::Context, pass it to the OnStats hook and switch all code to it
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r-- | src/modules/m_spanningtree/main.h | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/override_stats.cpp | 21 |
2 files changed, 15 insertions, 8 deletions
diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 3e02ce93f..2490c83ef 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -165,7 +165,7 @@ class ModuleSpanningTree : public Module void OnOper(User* user, const std::string &opertype) CXX11_OVERRIDE; void OnAddLine(User *u, XLine *x) CXX11_OVERRIDE; void OnDelLine(User *u, XLine *x) CXX11_OVERRIDE; - ModResult OnStats(char statschar, User* user, string_list &results) CXX11_OVERRIDE; + ModResult OnStats(Stats::Context& stats) CXX11_OVERRIDE; ModResult OnSetAway(User* user, const std::string &awaymsg) CXX11_OVERRIDE; void OnLoadModule(Module* mod) CXX11_OVERRIDE; void OnUnloadModule(Module* mod) CXX11_OVERRIDE; diff --git a/src/modules/m_spanningtree/override_stats.cpp b/src/modules/m_spanningtree/override_stats.cpp index 14b3f5ef7..b28c2d984 100644 --- a/src/modules/m_spanningtree/override_stats.cpp +++ b/src/modules/m_spanningtree/override_stats.cpp @@ -24,27 +24,34 @@ #include "utils.h" #include "link.h" -ModResult ModuleSpanningTree::OnStats(char statschar, User* user, string_list &results) +ModResult ModuleSpanningTree::OnStats(Stats::Context& stats) { - if ((statschar == 'c') || (statschar == 'n')) + if ((stats.GetSymbol() == 'c') || (stats.GetSymbol() == 'n')) { for (std::vector<reference<Link> >::iterator i = Utils->LinkBlocks.begin(); i != Utils->LinkBlocks.end(); ++i) { Link* L = *i; - results.push_back("213 "+user->nick+" "+statschar+" *@"+(L->HiddenFromStats ? "<hidden>" : L->IPAddr)+" * "+(*i)->Name.c_str()+" "+ConvToStr(L->Port)+" "+(L->Hook.empty() ? "plaintext" : L->Hook)); - if (statschar == 'c') - results.push_back("244 "+user->nick+" H * * "+L->Name.c_str()); + std::string ipaddr = "*@"; + if (L->HiddenFromStats) + ipaddr.append("<hidden>"); + else + ipaddr.append(L->IPAddr); + + const std::string hook = (L->Hook.empty() ? "plaintext" : L->Hook); + stats.AddRow(213, stats.GetSymbol(), ipaddr, '*', L->Name.c_str(), L->Port, hook); + if (stats.GetSymbol() == 'c') + stats.AddRow(244, 'H', '*', '*', L->Name.c_str()); } return MOD_RES_DENY; } - else if (statschar == 'U') + else if (stats.GetSymbol() == 'U') { ConfigTagList tags = ServerInstance->Config->ConfTags("uline"); for (ConfigIter i = tags.first; i != tags.second; ++i) { std::string name = i->second->getString("server"); if (!name.empty()) - results.push_back("248 "+user->nick+" U "+name); + stats.AddRow(248, 'U', name); } return MOD_RES_DENY; } |