diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
commit | 03929dac2a29664878d2c971648a4fe1fb698462 (patch) | |
tree | 02c5e2b3e006234aa29545f7a93a1ce01b291a8b /scripts/showhost.pl | |
parent | Initial commit. (diff) | |
download | irssi-scripts-03929dac2a29664878d2c971648a4fe1fb698462.tar.xz irssi-scripts-03929dac2a29664878d2c971648a4fe1fb698462.zip |
Adding upstream version 20231031.upstream/20231031upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/showhost.pl')
-rw-r--r-- | scripts/showhost.pl | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/scripts/showhost.pl b/scripts/showhost.pl new file mode 100644 index 0000000..9f2841b --- /dev/null +++ b/scripts/showhost.pl @@ -0,0 +1,68 @@ +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 [user@leet.hostname.org] 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'}); + |