aboutsummaryrefslogtreecommitdiff
path: root/src/coremods
diff options
context:
space:
mode:
authorGravatar Val Lorentz2022-03-19 19:13:10 +0100
committerGravatar GitHub2022-03-19 18:13:10 +0000
commit740e193f599ffcaa0e95926dd805e9a201d9ba78 (patch)
treea6e381e6519ddfc88c339970f62b2c54da1c1172 /src/coremods
parentUpdate the Windows dependencies. (diff)
Add support for the <count> param of WHOWAS (#1968)
Not very useful IMO, but every server but InspIRCd seems to implement it, and it's part of the RFCs: * https://datatracker.ietf.org/doc/html/rfc1459#section-4.5.3 * https://datatracker.ietf.org/doc/html/rfc2812#section-3.6.3
Diffstat (limited to 'src/coremods')
-rw-r--r--src/coremods/core_whowas.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/coremods/core_whowas.cpp b/src/coremods/core_whowas.cpp
index 893cd83be..d80a3a3d2 100644
--- a/src/coremods/core_whowas.cpp
+++ b/src/coremods/core_whowas.cpp
@@ -187,7 +187,7 @@ class CommandWhowas : public Command
CommandWhowas::CommandWhowas( Module* parent)
: Command(parent, "WHOWAS", 1)
{
- syntax = "<nick>";
+ syntax = "<nick> [<count>]";
Penalty = 2;
}
@@ -208,7 +208,15 @@ CmdResult CommandWhowas::Handle(User* user, const Params& parameters)
else
{
const WhoWas::Nick::List& list = nick->entries;
- for (WhoWas::Nick::List::const_reverse_iterator i = list.rbegin(); i != list.rend(); ++i)
+ WhoWas::Nick::List::const_reverse_iterator last = list.rend();
+ if (parameters.size() > 1)
+ {
+ size_t count = ConvToNum<size_t>(parameters[1]);
+ if (count > 0 && (size_t) std::distance(list.rbegin(), last) > count)
+ last = list.rbegin() + count;
+ }
+
+ for (WhoWas::Nick::List::const_reverse_iterator i = list.rbegin(); i != last; ++i)
{
WhoWas::Entry* u = *i;