diff options
author | Attila Molnar <attilamolnar@hush.com> | 2016-03-29 16:39:06 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2016-03-29 16:39:06 +0200 |
commit | 484b30f67b1479de72ff99532b7b91e775686e97 (patch) | |
tree | 701877c5a0b6ac267f00e8f439547dc60d620dbc | |
parent | ab115e4fe39c8aeb74482462dd6a473341fa7608 (diff) |
m_spanningtree Add CommandNum::Builder
-rw-r--r-- | src/modules/m_spanningtree/commands.h | 7 | ||||
-rw-r--r-- | src/modules/m_spanningtree/num.cpp | 15 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/modules/m_spanningtree/commands.h b/src/modules/m_spanningtree/commands.h index a65639434..4810e9d4b 100644 --- a/src/modules/m_spanningtree/commands.h +++ b/src/modules/m_spanningtree/commands.h @@ -21,6 +21,7 @@ #include "servercommand.h" #include "commandbuilder.h" +#include "remoteuser.h" /** Handle /RCONNECT */ @@ -375,6 +376,12 @@ class CommandNum : public ServerOnlyServerCommand<CommandNum> CommandNum(Module* Creator) : ServerOnlyServerCommand<CommandNum>(Creator, "NUM", 3) { } CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters); RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters); + + class Builder : public CmdBuilder + { + public: + Builder(SpanningTree::RemoteUser* target, const Numeric::Numeric& numeric); + }; }; class SpanningTreeCommands diff --git a/src/modules/m_spanningtree/num.cpp b/src/modules/m_spanningtree/num.cpp index 047dba432..2c8697c9a 100644 --- a/src/modules/m_spanningtree/num.cpp +++ b/src/modules/m_spanningtree/num.cpp @@ -21,6 +21,7 @@ #include "utils.h" #include "commands.h" +#include "remoteuser.h" CmdResult CommandNum::HandleServer(TreeServer* server, std::vector<std::string>& params) { @@ -45,3 +46,17 @@ RouteDescriptor CommandNum::GetRouting(User* user, const std::vector<std::string { return ROUTE_UNICAST(params[1]); } + +CommandNum::Builder::Builder(SpanningTree::RemoteUser* target, const Numeric::Numeric& numeric) + : CmdBuilder("NUM") +{ + TreeServer* const server = (numeric.GetServer() ? (static_cast<TreeServer*>(numeric.GetServer())) : Utils->TreeRoot); + push(server->GetID()).push(target->uuid).push(InspIRCd::Format("%03u", numeric.GetNumeric())); + const std::vector<std::string>& params = numeric.GetParams(); + if (!params.empty()) + { + for (std::vector<std::string>::const_iterator i = params.begin(); i != params.end()-1; ++i) + push(*i); + push_last(params.back()); + } +} |