html/opnotify.pl
1 use Irssi 20020300;
2 use strict;
3
4 use vars qw($VERSION %IRSSI);
5 $VERSION = "1.0";
6 %IRSSI = (
7 authors => "Maciek \'fahren\' Freudenheim",
8 contact => "fahren\@bochnia.pl",
9 name => "opnotify",
10 description => "Hilights window refnumber in statusbar if someone ops/deops you on channel",
11 license => "GNU GPLv2 or later",
12 changed => "Fri Mar 15 15:09:42 CET 2002"
13 );
14
15 sub event_modechange {
16 my ($server, $data, $nick) = @_;
17 my ($channel, $mode, $rest) = split(/ /, $data, 3);
18 my $win = Irssi::active_win();
19 my $winchan = $server->window_find_item($channel);
20
21 return if $win->{refnum} == $winchan->{refnum};
22
23 my @rest = split(/ +/, $rest);
24
25 # l4m3 but speeds-up
26 return unless grep {/^$server->{nick}$/} @rest;
27
28 my $par = undef;
29 my $ind = 0;
30 my $op = $winchan->{active}->{chanop};
31 my $gotop = $op;
32
33 for my $c (split(//, $mode)) {
34 if ($c =~ /[+-]/) {
35 $par = $c;
36 } elsif ($c eq "o") {
37 $gotop = ($par eq "+"? 1 : 0) if $rest[$ind++] eq $server->{nick};
38 } elsif ($c =~ /[vbkeIqhdO]/ || ($c eq "l" && $par eq "+")) {
39 $ind++;
40 }
41 }
42
43 $winchan->activity(4) unless $gotop == $op;
44 # Irssi::print("%R>>%n $nick " . (($gotop)? "opped" : "deopped") . " You on %_$channel%_ /" . $server->{tag} . "/") unless $gotop == $op;
45 }
46
47 Irssi::signal_add("event mode", "event_modechange");