diff options
author | Adam <Adam@anope.org> | 2015-01-05 16:31:09 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2015-01-05 19:00:51 -0500 |
commit | d79d8e2608e304760c42bdf87502e3bc51781b88 (patch) | |
tree | 179913b8b328f88d52d84c3453fceb28a2d63422 /src/command.cpp | |
parent | 8ab1c71d7dc7a0d47e5711dc72e3fc9c3ee850bb (diff) | |
parent | c46ec39e5088119cd21f5f7e16e64e61a876ca20 (diff) |
Merge branch '2.0' into 2.1
Conflicts:
CMakeLists.txt
include/modules.h
include/serialize.h
modules/commands/bs_assign.cpp
modules/commands/bs_badwords.cpp
modules/commands/bs_bot.cpp
modules/commands/bs_control.cpp
modules/commands/bs_kick.cpp
modules/commands/cs_access.cpp
modules/commands/cs_akick.cpp
modules/commands/cs_drop.cpp
modules/commands/cs_entrymsg.cpp
modules/commands/cs_flags.cpp
modules/commands/cs_info.cpp
modules/commands/cs_invite.cpp
modules/commands/cs_kick.cpp
modules/commands/cs_mode.cpp
modules/commands/cs_register.cpp
modules/commands/cs_seen.cpp
modules/commands/cs_set.cpp
modules/commands/cs_suspend.cpp
modules/commands/cs_topic.cpp
modules/commands/cs_unban.cpp
modules/commands/cs_xop.cpp
modules/commands/hs_del.cpp
modules/commands/hs_list.cpp
modules/commands/hs_request.cpp
modules/commands/ms_ignore.cpp
modules/commands/ms_send.cpp
modules/commands/ns_recover.cpp
modules/commands/ns_register.cpp
modules/commands/ns_suspend.cpp
modules/commands/os_dns.cpp
modules/commands/os_noop.cpp
modules/commands/os_oper.cpp
modules/commands/os_session.cpp
modules/database/db_sql_live.cpp
modules/encryption/enc_bcrypt.cpp
modules/extra/m_ldap_authentication.cpp
modules/extra/m_ldap_oper.cpp
modules/fantasy.cpp
modules/m_dnsbl.cpp
modules/m_sasl.cpp
modules/protocol/hybrid.cpp
modules/protocol/inspircd20.cpp
modules/protocol/unreal.cpp
modules/pseudoclients/chanserv.cpp
modules/pseudoclients/nickserv.cpp
modules/webcpanel/pages/chanserv/access.cpp
modules/webcpanel/webcpanel.cpp
modules/webcpanel/webcpanel.h
src/command.cpp
src/messages.cpp
src/modulemanager.cpp
src/regchannel.cpp
src/serialize.cpp
Diffstat (limited to 'src/command.cpp')
-rw-r--r-- | src/command.cpp | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/src/command.cpp b/src/command.cpp index c387ddaab..f7de4ccec 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -223,18 +223,6 @@ void Command::Run(CommandSource &source, const Anope::string &message) return; } - if (c->RequireUser() && !source.GetUser()) - return; - - // Command requires registered users only - if (!c->AllowUnregistered() && !source.nc) - { - source.Reply(_("Password authentication required for that command.")); - if (source.GetUser()) - Log(LOG_NORMAL, "access_denied_unreg", source.service) << "Access denied for unregistered user " << source.GetUser()->GetMask() << " with command " << it->first; - return; - } - for (unsigned i = 0, j = params.size() - (count - 1); i < j; ++i) params.erase(params.begin()); @@ -244,17 +232,34 @@ void Command::Run(CommandSource &source, const Anope::string &message) params.erase(params.begin() + c->max_params); } - source.command = it->first; + c->Run(source, it->first, info, params); +} + +void Command::Run(CommandSource &source, const Anope::string &cmdname, const CommandInfo &info, std::vector<Anope::string> ¶ms) +{ + if (this->RequireUser() && !source.GetUser()) + return; + + // Command requires registered users only + if (!this->AllowUnregistered() && !source.nc) + { + source.Reply(_("Password authentication required for that command.")); + if (source.GetUser()) + Log(LOG_NORMAL, "access_denied_unreg", source.service) << "Access denied for unregistered user " << source.GetUser()->GetMask() << " with command " << cmdname; + return; + } + + source.command = cmdname; source.permission = info.permission; EventReturn MOD_RESULT; - MOD_RESULT = Event::OnPreCommand(&Event::PreCommand::OnPreCommand, source, c, params); + MOD_RESULT = Event::OnPreCommand(&Event::PreCommand::OnPreCommand, source, this, params); if (MOD_RESULT == EVENT_STOP) return; - if (params.size() < c->min_params) + if (params.size() < this->min_params) { - c->OnSyntaxError(source, !params.empty() ? params[params.size() - 1] : ""); + this->OnSyntaxError(source, !params.empty() ? params[params.size() - 1] : ""); return; } @@ -266,12 +271,12 @@ void Command::Run(CommandSource &source, const Anope::string &message) else source.Reply(_("Access denied. You do not have access to command \002{0}\002."), info.permission); if (source.GetUser()) - Log(LOG_NORMAL, "access_denied", source.service) << "Access denied for user " << source.GetUser()->GetMask() << " with command " << it->first; + Log(LOG_NORMAL, "access_denied", source.service) << "Access denied for user " << source.GetUser()->GetMask() << " with command " << cmdname; return; } - c->Execute(source, params); - Event::OnPostCommand(&Event::PostCommand::OnPostCommand, source, c, params); + this->Execute(source, params); + Event::OnPostCommand(&Event::PostCommand::OnPostCommand, source, this, params); } bool Command::FindCommandFromService(const Anope::string &command_service, ServiceBot* &bot, Anope::string &name) |