本文整理汇总了C++中Command::IsDisabled方法的典型用法代码示例。如果您正苦于以下问题:C++ Command::IsDisabled方法的具体用法?C++ Command::IsDisabled怎么用?C++ Command::IsDisabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Command
的用法示例。
在下文中一共展示了Command::IsDisabled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessCommand
//.........这里部分代码省略.........
* this
* is
* a
* test
*/
// Iterator to the last parameter that will be kept
const std::vector<std::string>::iterator lastkeep = command_p.begin() + (handler->max_params - 1);
// Iterator to the first excess parameter
const std::vector<std::string>::iterator firstexcess = lastkeep + 1;
// Append all excess parameter(s) to the last parameter, seperated by spaces
for (std::vector<std::string>::const_iterator i = firstexcess; i != command_p.end(); ++i)
{
lastkeep->push_back(' ');
lastkeep->append(*i);
}
// Erase the excess parameter(s)
command_p.erase(firstexcess, command_p.end());
}
/*
* We call OnPreCommand here seperately if the command exists, so the magic above can
* truncate to max_params if necessary. -- w00t
*/
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, command_p, user, false, cmd));
if (MOD_RESULT == MOD_RES_DENY)
return;
/* activity resets the ping pending timer */
user->nping = ServerInstance->Time() + user->MyClass->GetPingTime();
if (handler->flags_needed)
{
if (!user->IsModeSet(handler->flags_needed))
{
user->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - You do not have the required operator privileges");
return;
}
if (!user->HasPermission(command))
{
user->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - Oper type %s does not have access to command %s",
user->oper->name.c_str(), command.c_str());
return;
}
}
if ((user->registered == REG_ALL) && (!user->IsOper()) && (handler->IsDisabled()))
{
/* command is disabled! */
if (ServerInstance->Config->DisabledDontExist)
{
user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s :Unknown command", command.c_str());
}
else
{
user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s :This command has been disabled.", command.c_str());
}
ServerInstance->SNO->WriteToSnoMask('a', "%s denied for %s (%[email protected]%s)",
command.c_str(), user->nick.c_str(), user->ident.c_str(), user->host.c_str());
return;
}
if ((!command_p.empty()) && (command_p.back().empty()) && (!handler->allow_empty_last_param))
command_p.pop_back();
if (command_p.size() < handler->min_params)
{
user->WriteNumeric(ERR_NEEDMOREPARAMS, "%s :Not enough parameters.", command.c_str());
if ((ServerInstance->Config->SyntaxHints) && (user->registered == REG_ALL) && (handler->syntax.length()))
user->WriteNumeric(RPL_SYNTAX, ":SYNTAX %s %s", handler->name.c_str(), handler->syntax.c_str());
return;
}
if ((user->registered != REG_ALL) && (!handler->WorksBeforeReg()))
{
user->WriteNumeric(ERR_NOTREGISTERED, "%s :You have not registered",command.c_str());
}
else
{
/* passed all checks.. first, do the (ugly) stats counters. */
handler->use_count++;
/* module calls too */
FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, command_p, user, true, cmd));
if (MOD_RESULT == MOD_RES_DENY)
return;
/*
* WARNING: be careful, the user may be deleted soon
*/
CmdResult result = handler->Handle(command_p, user);
FOREACH_MOD(OnPostCommand, (handler, command_p, user, result, cmd));
}
}