summaryrefslogtreecommitdiffstats
path: root/scripts/idlesince.pl
blob: 5e4b112817f8537bae78e233cf2f8a24853c335a (plain)
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
#!/usr/bin/perl

use strict;
use Irssi;
use Time::localtime;

use vars qw($VERSION %IRSSI);

$VERSION = "0.1";
%IRSSI = (
    authors     => "Leszek Matok",
    contact     => "lam\@lac.pl",
    name        => "idlesince",
    description => "Adds 'idle since' line to whois replies.",
    license     => "GPL",
    url         => "",
    changed     => "17.9.2002",
);

sub event_server_event {
    my ($server, $text, $sname) = @_;
    my @items = split(/ /,$text);
    
    my $idlesince = ctime(time()-$items[2]);
    $server->printformat($items[1], MSGLEVEL_CRAP, 'whois_idlesince',
	$items[1], $idlesince );
}

Irssi::theme_register([
    'whois_idlesince' => '{whois idlesince %|$1}'
]);
Irssi::signal_add_last('event 317', 'event_server_event');