diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bots.cpp | 14 | ||||
-rw-r--r-- | src/channels.cpp | 2 | ||||
-rw-r--r-- | src/command.cpp | 32 | ||||
-rw-r--r-- | src/config.cpp | 5 | ||||
-rw-r--r-- | src/misc.cpp | 2 | ||||
-rw-r--r-- | src/users.cpp | 51 |
6 files changed, 61 insertions, 45 deletions
diff --git a/src/bots.cpp b/src/bots.cpp index ea0bf4ec3..52773dd72 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -233,6 +233,7 @@ CommandInfo& BotInfo::SetCommand(const Anope::string &cname, const Anope::string { CommandInfo ci; ci.name = sname; + ci.cname = cname; ci.permission = permission; this->commands[cname] = ci; return this->commands[cname]; @@ -246,6 +247,19 @@ CommandInfo *BotInfo::GetCommand(const Anope::string &cname) return NULL; } +CommandInfo *BotInfo::FindCommand(const Anope::string &service) +{ + for (auto& it : commands) + { + CommandInfo &ci = it.second; + + if (ci.name == service) + return &ci; + } + + return nullptr; +} + BotInfo* BotInfo::Find(const Anope::string &nick, bool nick_only) { BotInfo *bi = NULL; diff --git a/src/channels.cpp b/src/channels.cpp index 9ba886c30..aff45fcd6 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -885,7 +885,7 @@ bool Channel::CheckKick(User *user) if (mask.empty()) mask = this->ci->GetIdealBan(user); if (reason.empty()) - reason = Language::Translate(user->Account(), CHAN_NOT_ALLOWED_TO_JOIN); + reason = Language::Translate(user->Account(), _("You are not permitted to be on this channel.")); Log(LOG_DEBUG) << "Autokicking " << user->nick << " (" << mask << ") from " << this->name; diff --git a/src/command.cpp b/src/command.cpp index 16070b221..59db22a4b 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -95,21 +95,6 @@ bool CommandSource::IsOper() return false; } -void CommandSource::Reply(const char *message, ...) -{ - va_list args; - char buf[4096]; // Messages can be really big. - - const char *translated_message = Language::Translate(this->nc, message); - - va_start(args, message); - vsnprintf(buf, sizeof(buf), translated_message, args); - - this->Reply(Anope::string(buf)); - - va_end(args); -} - void CommandSource::Reply(const Anope::string &message) { const char *translated_message = Language::Translate(this->nc, message.c_str()); @@ -149,13 +134,13 @@ void Command::SendSyntax(CommandSource &source) Anope::string s = Language::Translate(source.GetAccount(), _("Syntax")); if (!this->syntax.empty()) { - source.Reply("%s: \002%s %s\002", s.c_str(), source.command.c_str(), Language::Translate(source.GetAccount(), this->syntax[0].c_str())); + source.Reply("{0}: \002{1} {2}\002", s, source.command, Language::Translate(source.GetAccount(), this->syntax[0].c_str())); Anope::string spaces(s.length(), ' '); for (unsigned i = 1, j = this->syntax.size(); i < j; ++i) - source.Reply("%s \002%s %s\002", spaces.c_str(), source.command.c_str(), Language::Translate(source.GetAccount(), this->syntax[i].c_str())); + source.Reply("{0} \002{1} {2}\002", spaces, source.command, Language::Translate(source.GetAccount(), this->syntax[i].c_str())); } else - source.Reply("%s: \002%s\002", s.c_str(), source.command.c_str()); + source.Reply("{0}: \002{1}\002", s, source.command); } bool Command::AllowUnregistered() const @@ -185,7 +170,7 @@ const Anope::string Command::GetDesc(CommandSource &) const void Command::OnServHelp(CommandSource &source) { - source.Reply(" %-14s %s", source.command.c_str(), Language::Translate(source.nc, this->GetDesc(source).c_str())); + source.Reply(Anope::printf(" %-14s %s", source.command.c_str(), Language::Translate(source.nc, this->GetDesc(source).c_str()))); } bool Command::OnHelp(CommandSource &source, const Anope::string &subcommand) { return false; } @@ -195,7 +180,7 @@ void Command::OnSyntaxError(CommandSource &source, const Anope::string &subcomma this->SendSyntax(source); bool has_help = source.service->commands.find("HELP") != source.service->commands.end(); if (has_help) - source.Reply(MORE_INFO, Config->StrictPrivmsg.c_str(), source.service->nick.c_str(), source.command.c_str()); + source.Reply(_("\002{0}{1} HELP {2}\002 for more information."), Config->StrictPrivmsg, source.service->nick, source.command); } void Command::Run(CommandSource &source, const Anope::string &message) @@ -244,7 +229,7 @@ void Command::Run(CommandSource &source, const Anope::string &message) // Command requires registered users only if (!c->AllowUnregistered() && !source.nc) { - source.Reply(NICK_IDENTIFY_REQUIRED); + 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; @@ -276,7 +261,10 @@ void Command::Run(CommandSource &source, const Anope::string &message) // If the command requires a permission, and they aren't registered or don't have the required perm, DENIED if (!info.permission.empty() && !source.HasCommand(info.permission)) { - source.Reply(ACCESS_DENIED); + if (!source.IsOper()) + source.Reply(_("Access denied. You are not a Services Operator.")); + 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; return; diff --git a/src/config.cpp b/src/config.cpp index 2fb38107b..d14f1089f 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -452,6 +452,7 @@ Conf::Conf() : Block("") CommandInfo &c = this->Fantasy[nname]; c.name = service; + c.cname = nname; c.permission = permission; c.group = group; c.hide = hide; @@ -535,9 +536,13 @@ Conf::Conf() : Block("") regex_flags = std::regex::grep; else if (regex_engine == "egrep") regex_flags = std::regex::egrep; + else + regex_flags = static_cast<std::basic_regex<char>::flag_type>(0); /* always enable icase and optimize */ if (regex_flags) regex_flags |= std::regex::icase | std::regex::optimize; + + this->LineWrap = options->Get<unsigned>("linewrap", "200"); } Conf::~Conf() diff --git a/src/misc.cpp b/src/misc.cpp index a68028a70..b6891d669 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -371,7 +371,7 @@ Anope::string Anope::strftime(time_t t, const NickServ::Account *nc, bool short_ Anope::string Anope::Expires(time_t expires, const NickServ::Account *nc) { if (!expires) - return Language::Translate(nc, NO_EXPIRE); + return Language::Translate(nc, _("does not expire")); else if (expires <= Anope::CurTime) return Language::Translate(nc, _("expires momentarily")); else diff --git a/src/users.cpp b/src/users.cpp index 81fd13a33..47923a350 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -330,21 +330,6 @@ User::~User() Event::OnPostUserLogoff(&Event::PostUserLogoff::OnPostUserLogoff, this); } -void User::SendMessage(const MessageSource &source, const char *fmt, ...) -{ - va_list args; - char buf[BUFSIZE] = ""; - - const char *translated_message = Language::Translate(this, fmt); - - va_start(args, fmt); - vsnprintf(buf, BUFSIZE - 1, translated_message, args); - - this->SendMessage(source, Anope::string(buf)); - - va_end(args); -} - void User::SendMessage(const MessageSource &source, const Anope::string &msg) { const char *translated_message = Language::Translate(this, msg.c_str()); @@ -358,10 +343,34 @@ void User::SendMessage(const MessageSource &source, const Anope::string &msg) sepstream sep(translated_message, '\n', true); for (Anope::string tok; sep.GetToken(tok);) { - if (send_privmsg) - IRCD->SendPrivmsg(source, this->GetUID(), "%s", tok.c_str()); - else - IRCD->SendNotice(source, this->GetUID(), "%s", tok.c_str()); + if (tok.empty()) + tok = " "; + spacesepstream ssep(tok, true); + Anope::string buf; + for (Anope::string word; ssep.GetToken(word);) + { + if (word.empty()) + word = " "; + Anope::string add = buf.empty() ? word : " " + word; + if (buf.length() + add.length() > Config->LineWrap) + { + if (send_privmsg) + IRCD->SendPrivmsg(source, this->GetUID(), "%s", buf.c_str()); + else + IRCD->SendNotice(source, this->GetUID(), "%s", buf.c_str()); + buf.clear(); + add = word; + } + buf.append(add); + } + + if (!buf.empty()) + { + if (send_privmsg) + IRCD->SendPrivmsg(source, this->GetUID(), "%s", buf.c_str()); + else + IRCD->SendNotice(source, this->GetUID(), "%s", buf.c_str()); + } } } @@ -386,14 +395,14 @@ void User::Identify(NickServ::Nick *na) if (!this->nc->o->ot->modes.empty()) { this->SetModes(NULL, "%s", this->nc->o->ot->modes.c_str()); - this->SendMessage(Me, "Changing your usermodes to \002%s\002", this->nc->o->ot->modes.c_str()); + this->SendMessage(Me, "Changing your usermodes to \002{0}\002", this->nc->o->ot->modes); UserMode *um = ModeManager::FindUserModeByName("OPER"); if (um && !this->HasMode("OPER") && this->nc->o->ot->modes.find(um->mchar) != Anope::string::npos) IRCD->SendOper(this); } if (IRCD->CanSetVHost && !this->nc->o->vhost.empty()) { - this->SendMessage(Me, "Changing your vhost to \002%s\002", this->nc->o->vhost.c_str()); + this->SendMessage(Me, "Changing your vhost to \002{0}\002", this->nc->o->vhost); this->SetDisplayedHost(this->nc->o->vhost); IRCD->SendVhost(this, "", this->nc->o->vhost); } |