diff options
author | Adam <Adam@anope.org> | 2014-12-05 20:24:27 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2014-12-05 20:24:27 -0500 |
commit | e1f5e030bc8edac10da922e0402744b1e2f023c8 (patch) | |
tree | 4da3774510e5a3f1582e529cecb7f4abfba6b795 /modules/webcpanel/webcpanel.cpp | |
parent | afffeb0a1d49c1ac8f06ac9850929a41a52cbc7e (diff) |
Change webpanel access add to just add via the commands, split Command::Run into two so I can do this as I need to run named commands for it
Diffstat (limited to 'modules/webcpanel/webcpanel.cpp')
-rw-r--r-- | modules/webcpanel/webcpanel.cpp | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/modules/webcpanel/webcpanel.cpp b/modules/webcpanel/webcpanel.cpp index bf0a31540..134f07aa6 100644 --- a/modules/webcpanel/webcpanel.cpp +++ b/modules/webcpanel/webcpanel.cpp @@ -231,7 +231,7 @@ class ModuleWebCPanel : public Module namespace WebPanel { - void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, const std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key) + void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key) { ServiceReference<Command> cmd("Command", c); if (!cmd) @@ -266,14 +266,45 @@ namespace WebPanel my_reply(r, key); CommandSource source(user, NULL, nc, &my_reply, bi); + CommandInfo info; + info.name = c; + cmd->Run(source, "", info, params); + } - if (!cmd->AllowUnregistered() && !source.nc) + void RunCommandWithName(NickCore *nc, const Anope::string &service, const Anope::string &c, const Anope::string &cmdname, std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key) + { + ServiceReference<Command> cmd("Command", c); + if (!cmd) { - r[key] = "Access denied."; + r[key] = "Unable to find command " + c; return; } - cmd->Execute(source, params); + BotInfo *bi = Config->GetClient(service); + if (!bi) + return; + + CommandInfo *info = bi->GetCommand(cmdname); + if (!info) + return; + + struct MyComandReply : CommandReply + { + TemplateFileServer::Replacements &re; + const Anope::string &k; + + MyComandReply(TemplateFileServer::Replacements &_r, const Anope::string &_k) : re(_r), k(_k) { } + + void SendMessage(BotInfo *source, const Anope::string &msg) anope_override + { + re[k] = msg; + } + } + my_reply(r, key); + + CommandSource source(nc->display, NULL, nc, &my_reply, bi); + + cmd->Run(source, cmdname, *info, params); } } |