mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 18:49:03 -04:00
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
This commit is contained in:
parent
bc64702bb2
commit
740e193f59
@ -419,9 +419,11 @@ server.
|
||||
You should not use it during an established connection.
|
||||
">
|
||||
|
||||
<helpop key="whowas" title="/WHOWAS <nick>" value="
|
||||
<helpop key="whowas" title="/WHOWAS <nick> [<count>]" value="
|
||||
Returns a list of times the user was seen recently on IRC along with
|
||||
the time they were last seen and their server.
|
||||
|
||||
If <count> is given, only return the <count> most recent entries.
|
||||
">
|
||||
|
||||
<helpop key="links" title="/LINKS" value="
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user