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/ms_rsend.c | 135 +++++++++++++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 65 deletions(-) (limited to 'src/core/ms_rsend.c') diff --git a/src/core/ms_rsend.c b/src/core/ms_rsend.c index 90f581f3e..120a9e0de 100644 --- a/src/core/ms_rsend.c +++ b/src/core/ms_rsend.c @@ -15,21 +15,83 @@ #include "module.h" -int do_rsend(User * u); -void myMemoServHelp(User * u); +void myMemoServHelp(User *u); + +class CommandMSRSend : public Command +{ + public: + CommandMSRSend() : Command("RSEND", 2, 2) + { + } + + CommandResult Execute(User *u, std::vector ¶ms) + { + const char *name = params[0].c_str(); + const char *text = params[1].c_str(); + NickAlias *na = NULL; + int z = 3; + + /* prevent user from rsend to themselves */ + if ((na = findnick(name))) + { + if (u->na) + { + if (!stricmp(na->nc->display, u->na->nc->display)) + { + notice_lang(s_MemoServ, u, MEMO_NO_RSEND_SELF); + return MOD_CONT; + } + } + else + { + notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, name); + return MOD_CONT; + } + } + + if (MSMemoReceipt == 1) + { + /* Services opers and above can use rsend */ + if (is_services_oper(u)) + memo_send(u, name, text, z); + else + notice_lang(s_MemoServ, u, ACCESS_DENIED); + } + else if (MSMemoReceipt == 2) + /* Everybody can use rsend */ + memo_send(u, name, text, z); + else + { + /* rsend has been disabled */ + if (debug) + alog("debug: MSMemoReceipt is set misconfigured to %d", MSMemoReceipt); + notice_lang(s_MemoServ, u, MEMO_RSEND_DISABLED); + } + + return MOD_CONT; + } + + bool OnHelp(User *u, const std::string &subcommand) + { + notice_lang(s_MemoServ, u, MEMO_HELP_RSEND); + return true; + } + + void OnSyntaxError(User *u) + { + syntax_error(s_MemoServ, u, "RSEND", MEMO_RSEND_SYNTAX); + } +}; class MSRSend : public Module { public: MSRSend(const std::string &modname, const std::string &creator) : Module(modname, creator) { - Command *c; - this->SetAuthor("Anope"); this->SetVersion("$Id$"); this->SetType(CORE); - c = createCommand("RSEND", do_rsend, NULL, MEMO_HELP_RSEND, -1, -1, -1, -1); - this->AddCommand(MEMOSERV, c, MOD_UNIQUE); + this->AddCommand(MEMOSERV, new CommandMSRSend(), MOD_UNIQUE); this->SetMemoHelp(myMemoServHelp); if (!MSMemoReceipt) @@ -41,67 +103,10 @@ class MSRSend : public Module * Add the help response to anopes /ms help output. * @param u The user who is requesting help **/ -void myMemoServHelp(User * u) +void myMemoServHelp(User *u) { - if (((MSMemoReceipt == 1) && (is_services_oper(u))) - || (MSMemoReceipt == 2)) { + if ((MSMemoReceipt == 1 && is_services_oper(u)) || MSMemoReceipt == 2) notice_lang(s_MemoServ, u, MEMO_HELP_CMD_RSEND); - } -} - -/** - * The /ms rsend command. - * @param u The user who issued the command - * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. - **/ -int do_rsend(User * u) -{ - char *name = strtok(NULL, " "); - char *text = strtok(NULL, ""); - NickAlias *na = NULL; - int z = 3; - - - - /* check if the variables are here */ - if (!name || !text) { - notice_lang(s_MemoServ, u, MEMO_RSEND_SYNTAX); - return MOD_CONT; - } - - /* prevent user from rsend to themselves */ - if ((na = findnick(name))) { - if (u->na) { - if (stricmp(na->nc->display, u->na->nc->display) == 0) { - notice_lang(s_MemoServ, u, MEMO_NO_RSEND_SELF); - return MOD_CONT; - } - } else { - notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, name); - return MOD_CONT; - } - } - - if (MSMemoReceipt == 1) { - /* Services opers and above can use rsend */ - if (is_services_oper(u)) { - memo_send(u, name, text, z); - } else { - notice_lang(s_MemoServ, u, ACCESS_DENIED); - } - } else if (MSMemoReceipt == 2) { - /* Everybody can use rsend */ - memo_send(u, name, text, z); - } else { - /* rsend has been disabled */ - if (debug) { - alog("debug: MSMemoReceipt is set misconfigured to %d", - MSMemoReceipt); - } - notice_lang(s_MemoServ, u, MEMO_RSEND_DISABLED); - } - - return MOD_CONT; } MODULE_INIT("ms_rsend", MSRSend) -- cgit