mirror of
https://github.com/anope/anope.git
synced 2026-07-04 12:53:14 +02:00
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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user