]>
git.sthu.org Git - shutils.git/blob - dotfiles/irssi/scripts/topic-diff.pl
2 use vars
qw($VERSION %IRSSI);
8 authors => 'Pascal Hakim',
9 contact => 'pasc@redellipse.net',
11 description => 'This script shows you changes in the topic. ',
19 $topics{$channel->{server}->{tag}."_".$channel->{name}} = $channel->{topic};
23 my ($server, $channel, $topic, $user, $real) = @_;
30 # $server->print ($channel, $server->{tag});
32 if ($topics{$server->{tag}."_".$channel}) {
33 $topics{$server->{tag}."_".$channel} =~ s/^ +| +$//g;
34 $topic =~ s/^ +| +$//g;
35 my @original = split /\s*\|\s*|\s+-\s+/, $topics{$server->{tag}."_".$channel};
36 my @modified = split /\s*\|\s*|\s+-\s+/, $topic;
39 outer: while( $i <= $#original) {
40 if ($j <= $#modified && $original[$i] eq $modified[$j]) {
47 # First two don't match, check the rest of the list
48 for ($k = $j ; $k <= $#modified; $k++) {
49 if ($modified[$k] eq $original[$i])
56 $diff = ($diff ? $diff." | " : "").$original[$i];
62 if ($diff ne '') { $server->print ($channel, "Topic: -: ".$diff);}
64 $diff = join " | ", (grep {$_ ne ''} @modified);
66 if ($diff ne '') { $server->print ($channel, "Topic: +: ".$diff);}
69 $topics{$server->{tag}."_".$channel} = $topic;
74 # Start by reading all the channels currently opened, and recording their topic
76 my @channels = Irssi::channels () ;
78 foreach my $channel (@channels) {
79 $topics{$channel->{server}->{tag}."_".$channel->{name}} = $channel->{topic};
83 Irssi::signal_add 'message topic' => \& new_topic;
85 # We've joined a new channel
86 Irssi::signal_add 'channel joined' => \& new_channel;