summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-11-18 11:22:01 -0500
committerAdam <Adam@anope.org>2011-11-18 11:22:01 -0500
commitc43cdf438fb388c6989cca78d44be0c650c6c013 (patch)
tree080f742871b072d8a338f21fbe2067526f85b9f3
parent837421123996de045d240db6ee85e1215c8f436b (diff)
Added operserv/logout
-rw-r--r--data/operserv.example.conf3
-rw-r--r--modules/commands/os_login.cpp41
2 files changed, 41 insertions, 3 deletions
diff --git a/data/operserv.example.conf b/data/operserv.example.conf
index 29d4fd559..dbedb69e6 100644
--- a/data/operserv.example.conf
+++ b/data/operserv.example.conf
@@ -435,12 +435,13 @@ command { service = "OperServ"; name = "KILL"; command = "operserv/kill"; permis
/*
* os_login
*
- * Provides the command operserv/login.
+ * Provides the commands operserv/login and operserv/logout.
*
* Used to login to OperServ, only required if your oper block requires this.
*/
module { name = "os_login" }
command { service = "OperServ"; name = "LOGIN"; command = "operserv/login"; }
+command { service = "OperServ"; name = "LOGOUT"; command = "operserv/logout"; }
/*
* os_mode
diff --git a/modules/commands/os_login.cpp b/modules/commands/os_login.cpp
index d08310424..acaea5cc6 100644
--- a/modules/commands/os_login.cpp
+++ b/modules/commands/os_login.cpp
@@ -60,17 +60,54 @@ class CommandOSLogin : public Command
}
};
+class CommandOSLogout : public Command
+{
+ public:
+ CommandOSLogout(Module *creator) : Command(creator, "operserv/logout", 0, 0)
+ {
+ this->SetDesc(Anope::printf(_("Logout from to %s"), Config->OperServ.c_str()));
+ this->SetSyntax("");
+ }
+
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params)
+ {
+ Oper *o = source.u->Account()->o;
+ if (o == NULL)
+ source.Reply(_("No oper block for your nick."));
+ else if (o->password.empty())
+ source.Reply(_("Your oper block doesn't require logging in."));
+ else if (!source.u->HasExt("os_login_password_correct"))
+ source.Reply(_("You are not identified."));
+ else
+ {
+ Log(LOG_ADMIN, source.u, this);
+ source.u->Shrink("os_login_password_correct");
+ source.Reply(_("You have been logged out."));
+ }
+ }
+
+ bool OnHelp(CommandSource &source, const Anope::string &subcommand)
+ {
+ this->SendSyntax(source);
+ source.Reply(" ");
+ source.Reply(_("Logs you out from %s so you lose Services Operator privileges.\n"
+ "This command is only useful if your oper block is configured\n"
+ "with a password."), source.owner->nick.c_str());
+ return true;
+ }
+};
+
class OSLogin : public Module
{
CommandOSLogin commandoslogin;
+ CommandOSLogout commandoslogout;
public:
OSLogin(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
- commandoslogin(this)
+ commandoslogin(this), commandoslogout(this)
{
this->SetAuthor("Anope");
-
ModuleManager::Attach(I_IsServicesOper, this);
}