1use strict; 2use vars qw($VERSION %IRSSI); 3 4$VERSION = '0.4'; 5%IRSSI = ( 6 authors => 'Tijmen "timing" Ruizendaal', 7 contact => 'tijmen.ruizendaal@gmail.com', 8 name => 'bitlbee_blist', 9 description => '/blist <all|online|offline|away> <word>, greps <word> from blist for bitlbee', 10 license => 'GPLv2', 11 url => 'http://the-timing.nl/stuff/irssi-bitlbee', 12 changed => '2006-10-27', 13); 14 15my $bitlbee_server_tag = "localhost"; 16my $bitlbee_channel = "&bitlbee"; 17my ($list, $word); 18 19get_channel(); 20 21Irssi::signal_add_last 'channel sync' => sub { 22 my( $channel ) = @_; 23 if( $channel->{topic} eq "Welcome to the control channel. Type \x02help\x02 for help information." ){ 24 $bitlbee_server_tag = $channel->{server}->{tag}; 25 $bitlbee_channel = $channel->{name}; 26 } 27}; 28 29sub get_channel { 30 my @channels = Irssi::channels(); 31 foreach my $channel(@channels) { 32 if ($channel->{topic} eq "Welcome to the control channel. Type \x02help\x02 for help information.") { 33 $bitlbee_channel = $channel->{name}; 34 $bitlbee_server_tag = $channel->{server}->{tag}; 35 return 1; 36 } 37 } 38 return 0; 39} 40 41sub blist { 42 my ($args, $server, $winit) = @_; 43 ($list, $word) = split(/ /, $args, 2); 44 if (Irssi::active_win->{'active'}->{'name'} eq $bitlbee_channel) { 45 Irssi::active_win()->command("msg $bitlbee_channel blist $list"); 46 Irssi::signal_add('event privmsg', 'grep'); 47 } else { 48 print "Only use in $bitlbee_channel."; 49 } 50} 51 52sub grep { 53 my ($server, $data, $nick, $address) = @_; 54 my ($target, $text) = split(/ :/, $data, 2); 55 if ($text =~ /$word/ && $target =~ /$bitlbee_channel/){ 56 ##do nothing 57 } else {Irssi::signal_stop();} 58 if ($text =~ /buddies/ && $target =~/$bitlbee_channel/){Irssi::signal_remove('event privmsg', 'grep');} 59} 60 61Irssi::command_bind('blist','blist'); 62