-
Notifications
You must be signed in to change notification settings - Fork 235
/
showhost.pl
68 lines (56 loc) · 1.38 KB
/
showhost.pl
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
use strict;
use Irssi 20021028;
use vars qw($VERSION %IRSSI);
# Usage:
# To add the host by a kick, for example, use:
# /format kick {channick $0} {chanhost $host{$0}} was kicked from {channel $1} by {nick $2} {reason $3}
#
# Result:
# 19:23:42 -!- Nick [[email protected]] was kicked from #channel by MyNick [leet reason]
$VERSION = "0.2";
%IRSSI = (
authors => "Michiel v Vaardegem",
contact => "michielv\@zeelandnet.nl",
name => "showhost",
description => "show host kicks",
license => "GPL",
changed => "Mon Dec 8 19:23:51 CET 2003"
);
my $lasthost;
sub setlast
{
my ($server, $channelname, $nickname) = @_;
my @channels;
$lasthost = {};
if (defined($channelname))
{
$channels[0] = $server->channel_find($channelname);
if (!defined($channels[0]))
{
return;
}
}
else
{
@channels = $server->channels();
}
foreach my $channel (@channels)
{
my $nick = $channel->nick_find($nickname);
if (defined($nick))
{
$lasthost->{$channel->{'name'}} = $nick->{host};
}
}
}
sub expando_mode
{
my ($server,$item,$mode2) = @_;
if (!defined($item) || $item->{'type'} ne 'CHANNEL' )
{
return '';
}
return $lasthost->{$item->{'name'}};
}
Irssi::signal_add_first('message kick', sub {setlast($_[0],$_[1],$_[2]); });
Irssi::expando_create('host', sub {expando_mode($_[0],$_[1],0)},{ 'message part' => 'None'});