diff options
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); } } |