mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-03 08:32:42 +01:00
Factoids: rename top20
to top50
and add "referenced" subcommand
This commit is contained in:
parent
4162c06fe4
commit
722408d95e
@ -126,7 +126,7 @@
|
|||||||
* [factlog](Factoids.md#factlog)
|
* [factlog](Factoids.md#factlog)
|
||||||
* [count](Factoids.md#count)
|
* [count](Factoids.md#count)
|
||||||
* [histogram](Factoids.md#histogram)
|
* [histogram](Factoids.md#histogram)
|
||||||
* [top20](Factoids.md#top20)
|
* [top50](Factoids.md#top50)
|
||||||
<!-- md-toc-end -->
|
<!-- md-toc-end -->
|
||||||
|
|
||||||
## Command interpreter
|
## Command interpreter
|
||||||
@ -656,4 +656,4 @@ to have the command remember your location.
|
|||||||
##### [factlog](Factoids.md#factlog)
|
##### [factlog](Factoids.md#factlog)
|
||||||
##### [count](Factoids.md#count)
|
##### [count](Factoids.md#count)
|
||||||
##### [histogram](Factoids.md#histogram)
|
##### [histogram](Factoids.md#histogram)
|
||||||
##### [top20](Factoids.md#top20)
|
##### [top50](Factoids.md#top50)
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
* [factset](#factset-1)
|
* [factset](#factset-1)
|
||||||
* [count](#count)
|
* [count](#count)
|
||||||
* [histogram](#histogram)
|
* [histogram](#histogram)
|
||||||
* [top20](#top20)
|
* [top50](#top50)
|
||||||
<!-- md-toc-end -->
|
<!-- md-toc-end -->
|
||||||
|
|
||||||
## About
|
## About
|
||||||
@ -739,19 +739,19 @@ To see a histogram of the top factoid submitters, use the `histogram` command.
|
|||||||
<pragma-> !histogram
|
<pragma-> !histogram
|
||||||
<PBot> 268 factoids, top 10 submitters: twkm: 74 (27%) Major-Willard: 64 (23%) pragma-: 40 (14%) prec: 39 (14%) defrost: 14 (5%) PoppaVic: 10 (3%) infobahn: 7 (2%) orbitz: 3 (1%) mauke: 3 (1%) Tom^: 2 (1%)
|
<PBot> 268 factoids, top 10 submitters: twkm: 74 (27%) Major-Willard: 64 (23%) pragma-: 40 (14%) prec: 39 (14%) defrost: 14 (5%) PoppaVic: 10 (3%) infobahn: 7 (2%) orbitz: 3 (1%) mauke: 3 (1%) Tom^: 2 (1%)
|
||||||
|
|
||||||
### top20
|
### top50
|
||||||
To see the top 20 most popular factoids, use the `top20` command. It can also show you the 50 most recent factoids that were added or edited in a channel.
|
To see the top 50 most popular factoids, use the `top50` command. It can also show you the 50 most recent factoids that were added or edited in a channel.
|
||||||
|
|
||||||
Usage: `top20 <channel> [<nick> or 'added' or 'edited']`
|
Usage: `top50 <channel> [<nick> | 'added' | 'edited' | 'referenced']`
|
||||||
|
|
||||||
<pragma-> !top20 ##c
|
<pragma-> !top50 #c
|
||||||
<PBot> Top 20 referenced factoids for ##c: explain (3459) c11 (2148) book (1070) books (1049) K&R (1000) dontcastmalloc (991) notC (696) standard (655) c99 (506) scanf (501) declare (453) std (434) cstd (344) tias (305) parens (291) int (287) c1x (272) UB (263) H&S (257) binky (236)
|
<PBot> Top 50 referenced factoids for ##c: explain (3459) c11 (2148) book (1070) books (1049) K&R (1000) dontcastmalloc (991) notC (696) standard (655) c99 (506) scanf (501) declare (453) std (434) cstd (344) tias (305) parens (291) int (287) c1x (272) UB (263) H&S (257) binky (236)
|
||||||
|
|
||||||
<pragma-> !top20 ##c pragma-
|
<pragma-> !top50 #c pragma-
|
||||||
<PBot> 20 factoids last referenced by pragma- (pragma-!~chaos@unaffiliated/pragmatic-chaos): to [1d20h ago] realloc [3d15h ago] deport [4d16h ago] long [4d16h ago] decay [6d17h ago] x [6d16h ago] sizeof [13d18h ago] ENOQUESTION [13d19h ago] main [13d10h ago] cfaq [14d22h ago] heap [14d23h ago] malloc [15d15h ago] _ [16d20h ago] declareuse [17d15h ago] rot13 [17...
|
<PBot> 50 factoids last referenced by pragma- (pragma-!~chaos@unaffiliated/pragmatic-chaos): to [1d20h ago] realloc [3d15h ago] deport [4d16h ago] long [4d16h ago] decay [6d17h ago] x [6d16h ago] sizeof [13d18h ago] ENOQUESTION [13d19h ago] main [13d10h ago] cfaq [14d22h ago] heap [14d23h ago] malloc [15d15h ago] _ [16d20h ago] declareuse [17d15h ago] rot13 [17...
|
||||||
|
|
||||||
<pragma-> !top20 ##c added
|
<pragma-> !top50 #c added
|
||||||
<PBot> 50 most recent ##c submissions: barometer [9h ago by kurahaupo] glib-pcre [21h ago by aozt] unspecified [1d13h ago by pragma-] rules [1d17h ago by oldlaptop] pjp [2d3h ago by d3738] gnu-errno-name-num [2d21h ago by aozt] cbreak [5d8h ago by jp] test case [5d9h ago by pragma-] googlearn [6d2h ago by glacial] threads [8d10h ago by glacial] cjeopard...
|
<PBot> 50 most recent #c submissions: barometer [9h ago by kurahaupo] glib-pcre [21h ago by aozt] unspecified [1d13h ago by pragma-] rules [1d17h ago by oldlaptop] pjp [2d3h ago by d3738] gnu-errno-name-num [2d21h ago by aozt] cbreak [5d8h ago by jp] test case [5d9h ago by pragma-] googlearn [6d2h ago by glacial] threads [8d10h ago by glacial] cjeopard...
|
||||||
|
|
||||||
<pragma-> !top20 ##c edited
|
<pragma-> !top50 #c edited
|
||||||
<PBot> 50 most recent ##c edits: sanitizers [14h ago by nitrix] testing [1d6h ago by pragma-] typedef [1d8h ago by pragma-] license [2d4h ago by nitrix] diagnostics [2d19h ago by nitrix] tias [3d5h ago by pragma-] kr_lovecraft [4d1h ago by pragma-] cjeopardy [5d3h ago by pragma-] ...
|
<PBot> 50 most recent #c edits: sanitizers [14h ago by nitrix] testing [1d6h ago by pragma-] typedef [1d8h ago by pragma-] license [2d4h ago by nitrix] diagnostics [2d19h ago by nitrix] tias [3d5h ago by pragma-] kr_lovecraft [4d1h ago by pragma-] cjeopardy [5d3h ago by pragma-] ...
|
||||||
|
@ -228,7 +228,7 @@
|
|||||||
* [factset](Factoids.md#factset-1)
|
* [factset](Factoids.md#factset-1)
|
||||||
* [count](Factoids.md#count)
|
* [count](Factoids.md#count)
|
||||||
* [histogram](Factoids.md#histogram)
|
* [histogram](Factoids.md#histogram)
|
||||||
* [top20](Factoids.md#top20)
|
* [top50](Factoids.md#top50)
|
||||||
<!-- md-toc-end -->
|
<!-- md-toc-end -->
|
||||||
<!-- md-toc-begin -->
|
<!-- md-toc-begin -->
|
||||||
* [Registry](Registry.md#registry)
|
* [Registry](Registry.md#registry)
|
||||||
|
@ -62,7 +62,7 @@ sub initialize($self, %conf) {
|
|||||||
$self->{pbot}->{commands}->register(sub { $self->cmd_call_factoid(@_) }, "fact", 0);
|
$self->{pbot}->{commands}->register(sub { $self->cmd_call_factoid(@_) }, "fact", 0);
|
||||||
$self->{pbot}->{commands}->register(sub { $self->cmd_as_factoid(@_) }, "factoid", 0);
|
$self->{pbot}->{commands}->register(sub { $self->cmd_as_factoid(@_) }, "factoid", 0);
|
||||||
$self->{pbot}->{commands}->register(sub { $self->cmd_factfind(@_) }, "factfind", 0);
|
$self->{pbot}->{commands}->register(sub { $self->cmd_factfind(@_) }, "factfind", 0);
|
||||||
$self->{pbot}->{commands}->register(sub { $self->cmd_top20(@_) }, "top20", 0);
|
$self->{pbot}->{commands}->register(sub { $self->cmd_top50(@_) }, "top50", 0);
|
||||||
$self->{pbot}->{commands}->register(sub { $self->cmd_histogram(@_) }, "histogram", 0);
|
$self->{pbot}->{commands}->register(sub { $self->cmd_histogram(@_) }, "histogram", 0);
|
||||||
$self->{pbot}->{commands}->register(sub { $self->cmd_count(@_) }, "count", 0);
|
$self->{pbot}->{commands}->register(sub { $self->cmd_count(@_) }, "count", 0);
|
||||||
$self->{pbot}->{commands}->register(sub { $self->cmd_add_regex(@_) }, "regex", 1);
|
$self->{pbot}->{commands}->register(sub { $self->cmd_add_regex(@_) }, "regex", 1);
|
||||||
@ -1456,7 +1456,7 @@ sub cmd_factchange($self, $context) {
|
|||||||
return "Changed: $trigger_name is $action";
|
return "Changed: $trigger_name is $action";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub cmd_top20($self, $context) {
|
sub cmd_top50($self, $context) {
|
||||||
my $factoids = $self->{pbot}->{factoids}->{data}->{storage};
|
my $factoids = $self->{pbot}->{factoids}->{data}->{storage};
|
||||||
my %hash = ();
|
my %hash = ();
|
||||||
my $text = "";
|
my $text = "";
|
||||||
@ -1464,14 +1464,16 @@ sub cmd_top20($self, $context) {
|
|||||||
|
|
||||||
my ($channel, $args) = $self->{pbot}->{interpreter}->split_args($context->{arglist}, 2);
|
my ($channel, $args) = $self->{pbot}->{interpreter}->split_args($context->{arglist}, 2);
|
||||||
|
|
||||||
if (not defined $channel) { return "Usage: top20 <channel> [nick or 'added' or 'edited']"; }
|
if (!defined $channel || $channel ne '.*' && $channel !~ m/^#/) {
|
||||||
|
return "Usage: top50 <channel> [<nick> | 'added' | 'edited' | 'referenced']";
|
||||||
|
}
|
||||||
|
|
||||||
if (not defined $args) {
|
if (not defined $args) {
|
||||||
my $iter = $factoids->get_each('type = text', "index1 = $channel", 'index2', 'ref_count > 0', '_sort = -ref_count');
|
my $iter = $factoids->get_each('type = text', "index1 = $channel", 'index2', 'ref_count > 0', '_sort = -ref_count');
|
||||||
while (defined (my $factoid = $factoids->get_next($iter))) {
|
while (defined (my $factoid = $factoids->get_next($iter))) {
|
||||||
$text .= $factoids->get_data($factoid->{index1}, $factoid->{index2}, '_name') . " ($factoid->{ref_count}) ";
|
$text .= $factoids->get_data($factoid->{index1}, $factoid->{index2}, '_name') . " ($factoid->{ref_count}) ";
|
||||||
$i++;
|
$i++;
|
||||||
last if $i >= 20;
|
last if $i >= 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
$channel = "the global channel" if $channel eq '.*';
|
$channel = "the global channel" if $channel eq '.*';
|
||||||
@ -1514,6 +1516,22 @@ sub cmd_top20($self, $context) {
|
|||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lc $args eq 'referenced') {
|
||||||
|
my $iter = $factoids->get_each('type = text', "index1 = $channel", 'index2', 'last_referenced_on', 'ref_user', '_sort = -last_referenced_on');
|
||||||
|
while (defined (my $factoid = $factoids->get_next($iter))) {
|
||||||
|
last if not defined $factoid->{'last_referenced_on'};
|
||||||
|
my $ago = concise ago gettimeofday - $factoid->{'last_referenced_on'};
|
||||||
|
my ($ref_by) = $factoid->{'ref_user'} =~ /^([^!]+)/;
|
||||||
|
$text .= ' ' . $factoids->get_data($factoid->{index1}, $factoid->{index2}, '_name') . " [$ago by $ref_by]\n";
|
||||||
|
$i++;
|
||||||
|
last if $i >= 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
$channel = 'the global channel' if $channel eq '.*';
|
||||||
|
$text = "$i most recent references for $channel:\n\n$text" if $i > 0;
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
my $iter = $factoids->get_each('type = text', "index1 = $channel", 'index2', 'ref_user', 'last_referenced_on', '_sort = -last_referenced_on');
|
my $iter = $factoids->get_each('type = text', "index1 = $channel", 'index2', 'ref_user', 'last_referenced_on', '_sort = -last_referenced_on');
|
||||||
while (defined (my $factoid = $factoids->get_next($iter))) {
|
while (defined (my $factoid = $factoids->get_next($iter))) {
|
||||||
my ($ref_user) = $factoid->{ref_user} =~ /^([^!]+)/;
|
my ($ref_user) = $factoid->{ref_user} =~ /^([^!]+)/;
|
||||||
@ -1521,13 +1539,15 @@ sub cmd_top20($self, $context) {
|
|||||||
my $ago = $factoid->{'last_referenced_on'} ? concise ago(gettimeofday - $factoid->{'last_referenced_on'}) : "unknown";
|
my $ago = $factoid->{'last_referenced_on'} ? concise ago(gettimeofday - $factoid->{'last_referenced_on'}) : "unknown";
|
||||||
$text .= ' ' . $factoids->get_data($factoid->{index1}, $factoid->{index2}, '_name') . " [$ago]\n";
|
$text .= ' ' . $factoids->get_data($factoid->{index1}, $factoid->{index2}, '_name') . " [$ago]\n";
|
||||||
$i++;
|
$i++;
|
||||||
last if $i >= 20;
|
last if $i >= 50;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($i > 0) {
|
if ($i > 0) {
|
||||||
|
$channel = 'global channel' if $channel eq '.*';
|
||||||
return "$i $channel factoids last referenced by $args:\n\n$text";
|
return "$i $channel factoids last referenced by $args:\n\n$text";
|
||||||
} else {
|
} else {
|
||||||
|
$channel = 'the global channel' if $channel eq '.*';
|
||||||
return "No factoids last referenced by $args in $channel.";
|
return "No factoids last referenced by $args in $channel.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ use PBot::Imports;
|
|||||||
# These are set by the /misc/update_version script
|
# These are set by the /misc/update_version script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 4864,
|
BUILD_REVISION => 4865,
|
||||||
BUILD_DATE => "2024-11-30",
|
BUILD_DATE => "2024-11-30",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user