diff options
author | Sadie Powell <sadie@witchery.services> | 2024-10-22 16:16:32 +0100 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-10-22 16:29:22 +0100 |
commit | f1751dcb213b953ff362eda3276e210258a7cdb2 (patch) | |
tree | fab818dd75eaafee74d0b80e9d3da3e28aa0244c /src | |
parent | 8b026135492c13ae030b27cb6ec6c5b09131c0bd (diff) |
Replace usestrictprivmsg with something actually useful.
Every IRC server we support (other than Bahamut which is probably
on the chopping bock) uses UIDs so this setting does nothing.
Instead, allow configuring a server-side alias for each service
and use that when servicealias is enabled.
Diffstat (limited to 'src')
-rw-r--r-- | src/bots.cpp | 7 | ||||
-rw-r--r-- | src/command.cpp | 10 | ||||
-rw-r--r-- | src/config.cpp | 8 | ||||
-rw-r--r-- | src/messages.cpp | 10 |
4 files changed, 17 insertions, 18 deletions
diff --git a/src/bots.cpp b/src/bots.cpp index b109f8680..323fbc29a 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -265,6 +265,13 @@ CommandInfo *BotInfo::GetCommand(const Anope::string &cname) return NULL; } +Anope::string BotInfo::GetQueryCommand() const +{ + if (Config->ServiceAlias && !this->alias.empty()) + return Anope::printf("/%s", this->alias.c_str()); + return Anope::printf("/msg %s", this->nick.c_str()); +} + BotInfo *BotInfo::Find(const Anope::string &nick, bool nick_only) { if (!nick_only && IRCD != NULL && IRCD->RequiresID) diff --git a/src/command.cpp b/src/command.cpp index e242b50fb..ae391b433 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -199,7 +199,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(MORE_INFO, source.service->GetQueryCommand().c_str(), source.command.c_str()); } namespace @@ -226,13 +226,13 @@ namespace bool has_help = source.service->commands.find("HELP") != source.service->commands.end(); if (has_help && similar.empty()) { - source.Reply(_("Unknown command \002%s\002. \"%s%s HELP\" for help."), message.c_str(), - Config->StrictPrivmsg.c_str(), source.service->nick.c_str()); + source.Reply(_("Unknown command \002%s\002. \"%s HELP\" for help."), message.c_str(), + source.service->GetQueryCommand().c_str()); } else if (has_help) { - source.Reply(_("Unknown command \002%s\002. Did you mean \002%s\002? \"%s%s HELP\" for help."), - message.c_str(), similar.c_str(), Config->StrictPrivmsg.c_str(), source.service->nick.c_str()); + source.Reply(_("Unknown command \002%s\002. Did you mean \002%s\002? \"%s HELP\" for help."), + message.c_str(), similar.c_str(), source.service->GetQueryCommand().c_str()); } else if (similar.empty()) { diff --git a/src/config.cpp b/src/config.cpp index 28be07318..890cf57fe 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -195,8 +195,7 @@ Conf::Conf() : Block("") } this->ReadTimeout = options->Get<time_t>("readtimeout"); - this->UseStrictPrivmsg = options->Get<bool>("usestrictprivmsg"); - this->StrictPrivmsg = !UseStrictPrivmsg ? "/msg " : "/"; + this->ServiceAlias = options->Get<bool>("servicealias"); { std::vector<Anope::string> defaults; spacesepstream(this->GetModule("nickserv")->Get<const Anope::string>("defaults")).GetTokens(defaults); @@ -338,7 +337,8 @@ Conf::Conf() : Block("") &host = service->Get<const Anope::string>("host"), &gecos = service->Get<const Anope::string>("gecos"), &modes = service->Get<const Anope::string>("modes"), - &channels = service->Get<const Anope::string>("channels"); + &channels = service->Get<const Anope::string>("channels"), + &alias = service->Get<const Anope::string>("alias", nick.upper()); ValidateNotEmptyOrSpaces("service", "nick", nick); ValidateNotEmptyOrSpaces("service", "user", user); @@ -349,6 +349,8 @@ Conf::Conf() : Block("") BotInfo *bi = BotInfo::Find(nick, true); if (!bi) bi = new BotInfo(nick, user, host, gecos, modes); + + bi->alias = alias; bi->conf = true; std::vector<Anope::string> oldchannels = bi->botchannels; diff --git a/src/messages.cpp b/src/messages.cpp index b21a27f37..4c252f666 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -324,18 +324,8 @@ void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> ¶m if (!servername.equals_ci(Me->GetName())) return; } - else if (!IRCD->RequiresID && Config->UseStrictPrivmsg) - { - BotInfo *bi = BotInfo::Find(receiver); - if (!bi) - return; - Log(LOG_DEBUG) << "Ignored PRIVMSG without @ from " << u->nick; - u->SendMessage(bi, _("\"/msg %s\" is no longer supported. Use \"/msg %s@%s\" or \"/%s\" instead."), bi->nick.c_str(), bi->nick.c_str(), Me->GetName().c_str(), bi->nick.c_str()); - return; - } BotInfo *bi = BotInfo::Find(botname, nick_only); - if (bi) { Anope::string ctcpname, ctcpbody; |