new_parameters[extra] = item;
}
- CmdResult result = handler->Handle(user, new_parameters);
+ CommandBase::Params params(new_parameters, parameters.GetTags());
+ CmdResult result = handler->Handle(user, params);
if (localuser)
{
- // Run the OnPostCommand hook with the last parameter (original line) being empty
- // to indicate that the command had more targets in its original form.
+ // Run the OnPostCommand hook with the last parameter being true to indicate
+ // that the event is being called in a loop.
item.clear();
- FOREACH_MOD(OnPostCommand, (handler, new_parameters, localuser, result));
+ FOREACH_MOD(OnPostCommand, (handler, new_parameters, localuser, result, true));
}
}
}
if (user->IsModeSet(n->second->flags_needed))
{
/* if user has the flags, and now has the permissions, go ahead */
- if (user->HasPermission(commandname))
+ if (user->HasCommandPermission(commandname))
bOkay = true;
}
}
{
if (cmd)
*cmd = n->second;
- return n->second->Handle(user, parameters);
+
+ ClientProtocol::TagMap tags;
+ return n->second->Handle(user, CommandBase::Params(parameters, tags));
}
}
}
return CMD_INVALID;
}
-void CommandParser::ProcessCommand(LocalUser* user, std::string& command, Command::Params& command_p)
+void CommandParser::ProcessCommand(LocalUser* user, std::string& command, CommandBase::Params& command_p)
{
/* find the command, check it exists */
Command* handler = GetHandler(command);
return;
/* activity resets the ping pending timer */
- user->nping = ServerInstance->Time() + user->MyClass->GetPingTime();
+ user->nextping = ServerInstance->Time() + user->MyClass->GetPingTime();
if (handler->flags_needed)
{
return;
}
- if (!user->HasPermission(command))
+ if (!user->HasCommandPermission(command))
{
user->CommandFloodPenalty += failpenalty;
user->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Oper type %s does not have access to command %s",
}
}
- if ((user->registered == REG_ALL) && (!user->IsOper()) && (handler->IsDisabled()))
- {
- /* command is disabled! */
- user->CommandFloodPenalty += failpenalty;
- if (ServerInstance->Config->DisabledDontExist)
- {
- user->WriteNumeric(ERR_UNKNOWNCOMMAND, command, "Unknown command");
- }
- else
- {
- user->WriteNumeric(ERR_UNKNOWNCOMMAND, command, "This command has been disabled.");
- }
-
- ServerInstance->SNO->WriteToSnoMask('a', "%s denied for %s (%s@%s)",
- command.c_str(), user->nick.c_str(), user->ident.c_str(), user->GetRealHost().c_str());
- return;
- }
-
if ((!command_p.empty()) && (command_p.back().empty()) && (!handler->allow_empty_last_param))
command_p.pop_back();
*/
CmdResult result = handler->Handle(user, command_p);
- FOREACH_MOD(OnPostCommand, (handler, command_p, user, result));
+ FOREACH_MOD(OnPostCommand, (handler, command_p, user, result, false));
}
}
, min_params(minpara)
, max_params(maxpara)
, use_count(0)
- , disabled(false)
, works_before_reg(false)
, allow_empty_last_param(true)
, Penalty(1)
void CommandParser::ProcessBuffer(LocalUser* user, const std::string& buffer)
{
- size_t start = buffer.find_first_not_of(" ");
- if (start == std::string::npos)
- {
- // Discourage the user from flooding the server.
- user->CommandFloodPenalty += 2000;
- return;
- }
-
- ServerInstance->Logs->Log("USERINPUT", LOG_RAWIO, "C[%s] I %s", user->uuid.c_str(), buffer.c_str());
-
- irc::tokenstream tokens(buffer, start);
- std::string command;
- CommandBase::Params parameters;
-
- // Get the command name. This will always exist because of the check
- // at the start of the function.
- tokens.GetMiddle(command);
-
- // If this exists then the client sent a prefix as part of their
- // message. Section 2.3 of RFC 1459 technically says we should only
- // allow the nick of the client here but in practise everyone just
- // ignores it so we will copy them.
- if (command[0] == ':' && !tokens.GetMiddle(command))
- {
- // Discourage the user from flooding the server.
- user->CommandFloodPenalty += 2000;
+ ClientProtocol::ParseOutput parseoutput;
+ if (!user->serializer->Parse(user, buffer, parseoutput))
return;
- }
- // We upper-case the command name to ensure consistency internally.
+ std::string& command = parseoutput.cmd;
std::transform(command.begin(), command.end(), command.begin(), ::toupper);
- // Build the parameter map. We intentionally do not respect the RFC 1459
- // thirteen parameter limit here.
- std::string parameter;
- while (tokens.GetTrailing(parameter))
- parameters.push_back(parameter);
-
+ CommandBase::Params parameters(parseoutput.params, parseoutput.tags);
ProcessCommand(user, command, parameters);
}
{
}
-std::string CommandParser::TranslateUIDs(const std::vector<TranslateType>& to, const std::vector<std::string>& source, bool prefix_final, CommandBase* custom_translator)
+std::string CommandParser::TranslateUIDs(const std::vector<TranslateType>& to, const CommandBase::Params& source, bool prefix_final, CommandBase* custom_translator)
{
std::vector<TranslateType>::const_iterator types = to.begin();
std::string dest;
}
// If no custom translator was given, fall through
}
- case TR_TEXT:
+ /*@fallthrough@*/
default:
/* Do nothing */
dest.append(item);