* +------------------------------------+
*
* InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ * See: http://wiki.inspircd.org/Credits
*
* This program is free but copyrighted software; see
* the file COPYING for details.
*/
#include "inspircd.h"
-#include "commands/cmd_invite.h"
-extern "C" DllExport Command* init_command(InspIRCd* Instance)
+/** Handle /INVITE. These command handlers can be reloaded by the core,
+ * and handle basic RFC1459 commands. Commands within modules work
+ * the same way, however, they can be fully unloaded, where these
+ * may not.
+ */
+class CommandInvite : public Command
{
- return new CommandInvite(Instance);
-}
+ public:
+ /** Constructor for invite.
+ */
+ CommandInvite ( Module* parent) : Command(parent,"INVITE", 0, 0) { Penalty = 4; syntax = "[<nick> <channel>]"; }
+ /** Handle command.
+ * @param parameters The parameters to the comamnd
+ * @param pcnt The number of parameters passed to teh command
+ * @param user The user issuing the command
+ * @return A value from CmdResult to indicate command success or failure.
+ */
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
+};
/** Handle /INVITE
*/
CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, User *user)
{
- int MOD_RESULT = 0;
+ ModResult MOD_RESULT;
if (parameters.size() == 2 || parameters.size() == 3)
{
return CMD_FAILURE;
}
- FOREACH_RESULT(I_OnUserPreInvite,OnUserPreInvite(user,u,c,timeout));
+ FIRST_MOD_RESULT(OnUserPreInvite, MOD_RESULT, (user,u,c,timeout));
- if (MOD_RESULT == 1)
+ if (MOD_RESULT == MOD_RES_DENY)
{
return CMD_FAILURE;
}
- else if (MOD_RESULT == 0)
+ else if (MOD_RESULT == MOD_RES_PASSTHRU)
{
if (IS_LOCAL(user))
{
- if (c->GetStatus(user) < STATUS_HOP)
+ int rank = c->GetPrefixValue(user);
+ if (rank < HALFOP_VALUE)
{
- user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must be a channel %soperator", user->nick.c_str(), c->name.c_str(), c->GetStatus(u) == STATUS_HOP ? "" : "half-");
+ user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must be a channel %soperator",
+ user->nick.c_str(), c->name.c_str(), rank >= HALFOP_VALUE ? "" : "half-");
return CMD_FAILURE;
}
}
return CMD_SUCCESS;
}
+
+COMMAND_INIT(CommandInvite)