/usr/share/irssi/scripts/version-stat.pl is in irssi-scripts 20170711.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | #!/usr/bin/perl -w
# shows top[0-9]+ irc client versions in a channel
# by c0ffee
# - http://www.penguin-breeder.org/?page=irssi
#<scriptinfo>
use strict;
use vars qw($VERSION %IRSSI);
use Irssi 20020120;
$VERSION = "0.1";
%IRSSI = (
authors => "c0ffee",
contact => "c0ffee\@penguin-breeder.org",
name => "version-stats",
description => "shows top[0-9]+ irc client versions in a channel",
license => "Public Domain",
url => "http://www.penguin-breeder.org/?page=irssi",
changed => "Sun Apr 14 17:30 GMT 2002",
);
#</scriptinfo>
my %versions;
my $tag;
my $running = 0;
sub version_reply {
my ($server, $data, $nick, $addr, $target) = @_;
$versions{$data} = 1 + $versions{$data} if $running;
if (not Irssi::settings_get_bool('mute_version_reply') or not $running) {
Irssi::signal_emit("default ctcp reply", $server, "VERSION $data", $nick, $addr, $target);
}
}
sub show_stats {
my ($data) = @_;
my @stats = map "$versions{$_},$_", sort { $versions{$b} <=> $versions{$a} } keys %versions;
my ($top,$best,$cnt,$v,$foo,$bar);
$running = 0;
($top,$best) = $data =~ /(.*)\/(.*)/;
Irssi::print("VERSION stats:");
Irssi::timeout_remove($tag);
foreach (1..$top) {
last if not defined $stats[$_ - 1];
($cnt,$v) = $stats[$_ - 1] =~ /(.*?),(.*)/;
$bar = $cnt * 20 / $best;
$foo = "|" x $bar . "." x (20 - $bar),
Irssi::print("$_. [$foo]: ($cnt) $v");
}
}
sub cmd_vstat {
my ($data, $server, $channel) = @_;
my ($period, $top,@nicks,$num);
Irssi::print("usage: /vstat period-in-secs top-n"), return
if not (($period, $top) = $data =~ /(\d+)\s+(\d+)/);
@nicks = $channel->nicks();
$num = @nicks;
$tag = Irssi::timeout_add($period * 1000, 'show_stats', "$top/$num");
undef %versions;
$running = 1;
$server->send_raw("PRIVMSG $channel->{name} :\001VERSION\001");
Irssi::print("Starting version collection in $channel->{name}");
}
Irssi::signal_add_last('ctcp reply version', 'version_reply');
Irssi::command_bind('vstat', 'cmd_vstat');
Irssi::settings_add_bool('misc', 'mute_version_reply', 1);
|