1
0
mirror of https://github.com/anope/anope.git synced 2026-06-12 19:14:47 +02:00

Made os_noop more useful

This commit is contained in:
Adam
2012-11-06 00:00:36 -05:00
parent 0cf8d73395
commit 4cfd468863
2 changed files with 27 additions and 13 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ const Anope::string ServerFlagStrings[] = { "SERVER_NONE", "SERVER_SYNCING", "SE
/** Class representing a server
*/
class CoreExport Server : public Flags<ServerFlag>
class CoreExport Server : public Flags<ServerFlag>, public Extensible
{
private:
/* Server name */
+26 -12
View File
@@ -18,7 +18,7 @@ class CommandOSNOOP : public Command
public:
CommandOSNOOP(Module *creator) : Command(creator, "operserv/noop", 2, 2)
{
this->SetDesc(_("Temporarily remove all O:lines of a server remotely"));
this->SetDesc(_("Remove all operators from a server remotely"));
this->SetSyntax(_("SET \037server\037"));
this->SetSyntax(_("REVOKE \037server\037"));
}
@@ -31,13 +31,16 @@ class CommandOSNOOP : public Command
Server *s = Server::Find(server);
if (s == NULL)
source.Reply(_("Server %s does not exist."), server.c_str());
else if (s == Me || s->HasFlag(SERVER_JUPED))
source.Reply(_("You may not NOOP services."));
else if (cmd.equals_ci("SET"))
{
/* Remove the O:lines */
ircdproto->SendSVSNOOP(s, true);
s->Extend("noop", new ExtensibleItemClass<Anope::string>(source.GetNick()));
Log(LOG_ADMIN, source, this) << "SET on " << s->GetName();
source.Reply(_("All O:lines of \002%s\002 have been removed."), s->GetName().c_str());
source.Reply(_("All operators from \002%s\002 have been removed."), s->GetName().c_str());
Anope::string reason = "NOOP command used by " + source.GetNick();
/* Kill all the IRCops of the server */
@@ -46,32 +49,29 @@ class CommandOSNOOP : public Command
User *u2 = it->second;
++it;
if (u2 && u2->HasMode(UMODE_OPER) && u2->server == s)
if (u2->server == s && u2->HasMode(UMODE_OPER))
u2->Kill(Config->OperServ, reason);
}
}
else if (cmd.equals_ci("REVOKE"))
{
Log(LOG_ADMIN, source, this) << "REVOKE on " << s->GetName();
s->Shrink("noop");
ircdproto->SendSVSNOOP(s, false);
Log(LOG_ADMIN, source, this) << "REVOKE on " << s->GetName();
source.Reply(_("All O:lines of \002%s\002 have been reset."), s->GetName().c_str());
}
else
this->OnSyntaxError(source, "");
return;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("\002NOOP SET\002 remove all O:lines of the given\n"
"\002server\002 and kill all IRCops currently on it to\n"
"prevent them from rehashing the server (because this\n"
"would just cancel the effect).\n"
"\002NOOP REVOKE\002 makes all removed O:lines available again\n"
"on the given \002server\002.\n"));
source.Reply(_("\002SET\002 kills all operators from the given\n"
"\002server\002 and prevents operators from opering\n"
"up on the given server. \002REVOKE\002 removes this\n"
"restriction."));
return true;
}
};
@@ -86,6 +86,20 @@ class OSNOOP : public Module
{
this->SetAuthor("Anope");
ModuleManager::Attach(I_OnUserModeSet, this);
}
void OnUserModeSet(User *u, UserModeName Name) anope_override
{
if (Name == UMODE_OPER && u->server->HasExt("noop"))
{
Anope::string *setter = u->server->GetExt<ExtensibleItemClass<Anope::string> *>("noop");
if (setter)
{
Anope::string reason = "NOOP command used by " + *setter;
u->Kill(Config->OperServ, reason);
}
}
}
};