summaryrefslogtreecommitdiff
path: root/src/bots.cpp
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2025-04-09 18:17:02 +0100
committerSadie Powell <sadie@witchery.services>2025-04-10 13:34:25 +0100
commit9351debd73cb22f33bc46c201c9d66ec09ea773e (patch)
treebe92bdd1d1f288f375d6ff7fa00afc3db75e255d /src/bots.cpp
parent40d558ef21a438bf1dff9ac522cd852166fc4c44 (diff)
Expand GetQueryCommand to take a command name.
Diffstat (limited to 'src/bots.cpp')
-rw-r--r--src/bots.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/bots.cpp b/src/bots.cpp
index b01b7389f..d2cbd0cb4 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -271,11 +271,35 @@ CommandInfo *BotInfo::GetCommand(const Anope::string &cname)
return NULL;
}
-Anope::string BotInfo::GetQueryCommand() const
+Anope::string BotInfo::GetQueryCommand(const Anope::string &command, const Anope::string &extra) const
{
+ Anope::string buf;
if (Config->ServiceAlias && !this->alias.empty())
- return Anope::printf("/%s", this->alias.c_str());
- return Anope::printf("/msg %s", this->nick.c_str());
+ buf.append("/").append(this->alias);
+ else
+ buf.append("/msg ").append(this->nick);
+
+ if (!command.empty())
+ {
+ Anope::string actual_command = "\036(MISSING)\036";
+ for (const auto &[c_name, info] : this->commands)
+ {
+ if (info.name != command)
+ continue; // Wrong command.
+
+ actual_command = c_name;
+ if (!info.hide)
+ break; // Keep going to find a non-hidden alternative.
+ }
+
+ if (!actual_command.empty())
+ buf.append(" ").append(actual_command);
+ }
+
+ if (!extra.empty())
+ buf.append(" ").append(extra);
+
+ return buf;
}
BotInfo *BotInfo::Find(const Anope::string &nick, bool nick_only)