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/bs_unassign.c | 75 ++++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 33 deletions(-) (limited to 'src/core/bs_unassign.c') diff --git a/src/core/bs_unassign.c b/src/core/bs_unassign.c index 9066be2dd..fd8f487a6 100644 --- a/src/core/bs_unassign.c +++ b/src/core/bs_unassign.c @@ -18,18 +18,56 @@ int do_unassign(User * u); void myBotServHelp(User * u); +class CommandBSUnassign : public Command +{ + public: + CommandBSUnassign() : Command("UNASSIGN", 1, 1) + { + } + + CommandReturn Execute(User *u, std::vector ¶ms) + { + const char *chan = params[0].c_str(); + ChannelInfo *ci; + + if (readonly) + notice_lang(s_BotServ, u, BOT_ASSIGN_READONLY); + else if (!(ci = cs_findchan(chan))) + notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); + else if (ci->flags & CI_VERBOTEN) + notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); + else if (!is_services_admin(u) && !check_access(u, ci, CA_ASSIGN)) + notice_lang(s_BotServ, u, ACCESS_DENIED); + else if (!ci->bi) + notice_help(s_BotServ, u, BOT_NOT_ASSIGNED); + else { + ci->bi->UnAssign(u, ci); + notice_lang(s_BotServ, u, BOT_UNASSIGN_UNASSIGNED, ci->name); + } + return MOD_CONT; + } + + bool OnHelp(User *u, const std::string &subcommand) + { + notice_lang(s_BotServ, u, BOT_HELP_UNASSIGN); + return true; + } + + void OnBadSyntax(User *u) + { + syntax_error(s_BotServ, u, "UNASSIGN", BOT_UNASSIGN_SYNTAX); + } +}; + class BSUnassign : public Module { public: BSUnassign(const std::string &modname, const std::string &creator) : Module(modname, creator) { - Command *c; - this->SetAuthor("Anope"); this->SetVersion("$Id$"); this->SetType(CORE); - c = createCommand("UNASSIGN", do_unassign, NULL, BOT_HELP_UNASSIGN, -1, -1, -1, -1); - this->AddCommand(BOTSERV, c, MOD_UNIQUE); + this->AddCommand(BOTSERV, new CommandBSUnassign, MOD_UNIQUE); this->SetBotHelp(myBotServHelp); } @@ -46,33 +84,4 @@ void myBotServHelp(User * u) notice_lang(s_BotServ, u, BOT_HELP_CMD_UNASSIGN); } -/** - * The /bs unassign command. - * @param u The user who issued the command - * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. - **/ -int do_unassign(User * u) -{ - char *chan = strtok(NULL, " "); - ChannelInfo *ci; - - if (readonly) - notice_lang(s_BotServ, u, BOT_ASSIGN_READONLY); - else if (!chan) - syntax_error(s_BotServ, u, "UNASSIGN", BOT_UNASSIGN_SYNTAX); - else if (!(ci = cs_findchan(chan))) - notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); - else if (ci->flags & CI_VERBOTEN) - notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); - else if (!is_services_admin(u) && !check_access(u, ci, CA_ASSIGN)) - notice_lang(s_BotServ, u, ACCESS_DENIED); - else if (!ci->bi) - notice_help(s_BotServ, u, BOT_NOT_ASSIGNED); - else { - ci->bi->UnAssign(u, ci); - notice_lang(s_BotServ, u, BOT_UNASSIGN_UNASSIGNED, ci->name); - } - return MOD_CONT; -} - MODULE_INIT("bs_unassign", BSUnassign) -- cgit