Last active
December 18, 2015 20:48
-
-
Save saihtaM/5842403 to your computer and use it in GitHub Desktop.
irssi script: Show Common Channels in Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Irssi; | |
use vars qw($VERSION %IRSSI); | |
$VERSION = "1.2"; | |
%IRSSI = ( | |
authors => "Mathias", | |
contact => "#Mathias @ irc.QuakeNet.org", | |
name => "Show Common Channels in Query", | |
description => "When a new query window opens, the script automatically lists the channels you have in common with the other user.", | |
license => "BSD 4-Clause", # http://en.wikipedia.org/wiki/BSD_licenses#4-clause_license_.28original_.22BSD_License.22.29 | |
url => "http://okey.dk/" | |
#This was/is my first IRSSI script. | |
); | |
sub new_window_co_ch ($$) { | |
my ($win, $wi) = @_; return unless (ref $wi && $wi->{type} eq 'QUERY'); | |
foreach my $channel ($wi->{'server'}->channels()) { | |
foreach my $nick ($channel->nicks()) { | |
if($nick->{nick} eq $wi->{name}) { | |
$temp = ""; | |
if ($nick->{op}) { $temp .= "@"; } | |
if ($nick->{voice}) { $temp .= "+"; } | |
$temp .= $channel->{name}; | |
push(@common, $temp); | |
} | |
} | |
} | |
@common = sort(@common); | |
foreach $temp (@common) { $count++; } | |
if ($count > 0) { | |
$text = "You and ".$wi->{name}." are both on these channels: ".join(", ",@common)." (".$count.")"; | |
} else { | |
$text = "You and ".$wi->{name}." have no channels in common."; | |
} | |
$wi->print($text) if $text; | |
undef @common; | |
undef $count; | |
} | |
Irssi::signal_add('window item new', 'new_window_co_ch'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment