From d7d01bdc5c667a1fafd95241282b58e03b4caa5b Mon Sep 17 00:00:00 2001 From: rburchell Date: Mon, 9 Feb 2009 21:01:05 +0000 Subject: Squashed commit: merge next (1.9.1) back to trunk. SVN users, NOTE: THIS WILL NOT BUILD, NOR SHOULD YOU RUN IT YET. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1953 5417fbe8-f217-4b02-8779-1006273d7864 --- src/core/os_oline.c | 114 ++++++++++++++++++++++++++++------------------------ 1 file changed, 62 insertions(+), 52 deletions(-) (limited to 'src/core/os_oline.c') diff --git a/src/core/os_oline.c b/src/core/os_oline.c index 1764e401c..66f811b2c 100644 --- a/src/core/os_oline.c +++ b/src/core/os_oline.c @@ -14,23 +14,77 @@ /*************************************************************************/ #include "module.h" -int do_operoline(User * u); -void myOperServHelp(User * u); +void myOperServHelp(User *u); + +class CommandOSOLine : public Command +{ + public: + CommandOSOLine() : Command("OLINE", 2, 2) + { + } + + CommandResult Execute(User *u, std::vector ¶ms) + { + const char *nick = params[0].c_str(); + const char *flags = params[1].c_str(); + User *u2 = NULL; + + /* Only allow this if SuperAdmin is enabled */ + if (!u->isSuperAdmin) + { + notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY); + return MOD_CONT; + } + + /* let's check whether the user is online */ + if (!(u2 = finduser(nick))) + notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick); + else if (u2 && flags[0] == '+') + { + ircdproto->SendSVSO(s_OperServ, nick, flags); + ircdproto->SendMode(findbot(s_OperServ), nick, "+o"); + common_svsmode(u2, "+o", NULL); + notice_lang(s_OperServ, u2, OPER_OLINE_IRCOP); + notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick); + ircdproto->SendGlobops(s_OperServ, "\2%s\2 used OLINE for %s", u->nick, nick); + } + else if (u2 && flags[0] == '-') + { + ircdproto->SendSVSO(s_OperServ, nick, flags); + notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick); + ircdproto->SendGlobops(s_OperServ, "\2%s\2 used OLINE for %s", u->nick, nick); + } + else + this->OnSyntaxError(u); + return MOD_CONT; + } + + bool OnHelp(User *u, const std::string &subcommand) + { + if (!is_services_root(u)) + return false; + + notice_lang(s_OperServ, u, OPER_HELP_OLINE); + return true; + } + + void OnSyntaxError(User *u) + { + syntax_error(s_OperServ, u, "OLINE", OPER_OLINE_SYNTAX); + } +}; class OSOLine : public Module { public: OSOLine(const std::string &modname, const std::string &creator) : Module(modname, creator) { - Command *c; - this->SetAuthor("Anope"); this->SetVersion("$Id$"); this->SetType(CORE); - c = createCommand("OLINE", do_operoline, is_services_root, OPER_HELP_OLINE, -1, -1, -1, -1); - this->AddCommand(OPERSERV, c, MOD_UNIQUE); + this->AddCommand(OPERSERV, new CommandOSOLine(), MOD_UNIQUE); this->SetOperHelp(myOperServHelp); @@ -45,54 +99,10 @@ class OSOLine : public Module * Add the help response to anopes /os help output. * @param u The user who is requesting help **/ -void myOperServHelp(User * u) +void myOperServHelp(User *u) { - if (is_services_admin(u) && u->isSuperAdmin) { + if (is_services_admin(u) && u->isSuperAdmin) notice_lang(s_OperServ, u, OPER_HELP_CMD_OLINE); - } -} - -/** - * The /os oline command. - * @param u The user who issued the command - * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. - **/ -int do_operoline(User * u) -{ - char *nick = strtok(NULL, " "); - char *flags = strtok(NULL, ""); - User *u2 = NULL; - - /* Only allow this if SuperAdmin is enabled */ - if (!u->isSuperAdmin) { - notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY); - return MOD_CONT; - } - - if (!nick || !flags) { - syntax_error(s_OperServ, u, "OLINE", OPER_OLINE_SYNTAX); - return MOD_CONT; - } else { - /* let's check whether the user is online */ - if (!(u2 = finduser(nick))) { - notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick); - } else if (u2 && flags[0] == '+') { - ircdproto->SendSVSO(s_OperServ, nick, flags); - ircdproto->SendMode(findbot(s_OperServ), nick, "+o"); - common_svsmode(u2, "+o", NULL); - notice_lang(s_OperServ, u2, OPER_OLINE_IRCOP); - notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick); - ircdproto->SendGlobops(s_OperServ, "\2%s\2 used OLINE for %s", - u->nick, nick); - } else if (u2 && flags[0] == '-') { - ircdproto->SendSVSO(s_OperServ, nick, flags); - notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick); - ircdproto->SendGlobops(s_OperServ, "\2%s\2 used OLINE for %s", - u->nick, nick); - } else - syntax_error(s_OperServ, u, "OLINE", OPER_OLINE_SYNTAX); - } - return MOD_CONT; } MODULE_INIT("os_oline", OSOLine) -- cgit