Skip to content

Instantly share code, notes, and snippets.

@Zoddo
Last active January 3, 2016 14:18
Show Gist options
  • Save Zoddo/406b6434e65ed79bc666 to your computer and use it in GitHub Desktop.
Save Zoddo/406b6434e65ed79bc666 to your computer and use it in GitHub Desktop.
/os raw command for Anope 2.0 - DANGEROUS COMMAND!
#include "module.h"
class CommandOsRaw : public Command
{
public:
CommandOsRaw(Module *creator, const Anope::string &sname = "operserv/raw") : Command(creator, sname, 0, 0)
{
this->SetDesc(_("Send a raw command to the uplink server - \037DANGEROUS!\037"));
this->SetSyntax("\037<pseudoclient>\037 \037<command>\037");
this->SetSyntax(":\037<command>\037");
}
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
if (params.empty())
return;
Anope::string msg;
if (params[0][0] != ':')
{
for (unsigned i=0; i<params.size(); i++)
msg += params.at(i) + ' ';
UplinkSocket::Message() << msg;
}
else if (params.size() >= 2)
{
Anope::string botnick = params[0];
botnick.erase(0, 1);
BotInfo *bi = BotInfo::Find(botnick);
if (!bi)
{
source.Reply(BOT_DOES_NOT_EXIST, botnick.c_str());
return;
}
for (unsigned i=1; i<params.size(); i++)
msg += params.at(i) + ' ';
UplinkSocket::Message(bi) << msg;
}
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Send a raw command to the uplink server."));
source.Reply(" ");
source.Reply(_("\037This is a dangerous command. Use only\037\n"
"\037if you known what you do!\037"));
return true;
}
};
class ModuleOsRaw : public Module
{
CommandOsRaw commandosraw;
public:
ModuleOsRaw (const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, THIRD), commandosraw(this)
{
this->SetAuthor("Zoddo");
this->SetVersion("1.0.0");
}
};
MODULE_INIT(ModuleOsRaw)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment