diff options
| author | Sadie Powell <sadie@witchery.services> | 2024-06-12 17:45:05 +0100 |
|---|---|---|
| committer | Sadie Powell <sadie@witchery.services> | 2024-06-12 17:46:07 +0100 |
| commit | 24375d53e6d970d95d5e224cfce0f2bce60c6071 (patch) | |
| tree | bdb2b008eafc6ebe03ecfdec195306d4661b7be7 /modules/nickserv | |
| parent | 88ac47e2178a4e1996211fe5f7b2e692c8fcd319 (diff) | |
Add support for looking up account information from a nick.
Closes #407.
Diffstat (limited to 'modules/nickserv')
| -rw-r--r-- | modules/nickserv/ns_info.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/modules/nickserv/ns_info.cpp b/modules/nickserv/ns_info.cpp index 8a27af8b6..fb43aacd0 100644 --- a/modules/nickserv/ns_info.cpp +++ b/modules/nickserv/ns_info.cpp @@ -24,8 +24,35 @@ public: void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { + Anope::string nick; + if (params.empty()) + { + // Use the display of the source if logged in; otherwise, use their nick. + nick = source.nc ? source.nc->na->nick : source.GetNick(); + } + else if (params[0][0] == '=' && params[0].length() > 1) + { + // Look up the account of the specified user. + nick = params[0].substr(1); + auto *u = User::Find(nick); + if (!u) + { + source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); + return; + } + if (!u->AccountNick()) + { + source.Reply("User \002%s\002 isn't currently logged in to an account.", nick.c_str()); + return; + } + nick = u->AccountNick()->nick; + } + else + { + // Just use the nick the user specified. + nick = params[0]; + } - const Anope::string &nick = params.size() ? params[0] : (source.nc ? source.nc->display : source.GetNick()); NickAlias *na = NickAlias::Find(nick); bool has_auspex = source.HasPriv("nickserv/auspex"); |
