1#!/usr/local/bin/perl -w 2 3## Bugreports and Licence disclaimer. 4# 5# For bugreports and other improvements contact Geert Hauwaerts <geert@irssi.org> 6# 7# This program is free software; you can redistribute it and/or modify 8# it under the terms of the GNU General Public License as published by 9# the Free Software Foundation; either version 2 of the License, or 10# (at your option) any later version. 11# 12# This program is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15# GNU General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License 18# along with this script; if not, write to the Free Software 19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20# 21## 22 23use strict; 24use Irssi; 25use vars qw($VERSION %IRSSI); 26 27$VERSION = "1.08"; 28 29%IRSSI = ( 30 authors => 'Geert Hauwaerts', 31 contact => 'geert@irssi.org', 32 name => 'kline_warning.pl', 33 description => 'This script shows a warning in the statuswindow if somebody preforms a /KlINE or /UNKLINE.', 34 license => 'GNU General Public License', 35 url => 'http://irssi.hauwaerts.be/kline_warning.pl', 36 changed => 'Wed Sep 17 23:00:11 CEST 2003', 37); 38 39## Comments and remarks. 40# 41# This script uses settings, by default the servernotice will be stripped out. 42# If you still want to be able to see the servernotice use /SET or /TOGGLE 43# to switch it on or off. 44# 45# Setting: show_kline_snote 46# 47## 48 49Irssi::theme_register([ 50 'kline_added', '%_Warning%_: %R>>%n %_$0%_ added a K-Line for %_$1%_ on $2', 51 'tkline_added', '%_Warning%_: %R>>%n %_$0%_ added a temporary K-Line ($1) for %_$2%_ on $3', 52 'expired', '%_Warning%_: %R>>%n Temporary K-Line for %_$0%_ expired on $1', 53 'remove', '%_Warning%_: %R>>%n %_$0%_ removed the K-Line for %_$1%_ on $2', 54 'kline_warning_loaded', '%R>>%n %_Scriptinfo:%_ Loaded $0 version $1 by $2.' 55]); 56 57sub kline_warning { 58 59 my ($dest, $text) = @_; 60 61 return if (($text !~ /^NOTICE/)); 62 63 # Type IRCd: Hybrid7 64 # Homepage: http://www.ircd-hybrid.com/ 65 # Needed flags: +s 66 if ($text =~ /Notice -- (.*)!.*@.*{.*} added K-Line for \[(.*)\] \[.*\]/) { 67 print_warning_kline($1, $2, $dest->{tag}); 68 } elsif ($text =~ /Notice -- \*\*\* Received K-Line for \[(.*)\] \[.*\], from (.*)!.*@.* on .*/) { 69 print_warning_kline($2, $1, $dest->{tag}); 70 } elsif ($text =~ /Added K-Line \[.*@.*\]/) { 71 Irssi::signal_stop(); 72 } elsif ($text =~ /Notice -- (.*)!.*@.*{.*} added temporary (.*). K-Line for \[(.*)\] \[.*\]/) { 73 print_warning_tkline($1, $2, $3, $dest->{tag}); 74 } elsif ($text =~ /Added temporary .*. K-Line \[.*@.*\]/) { 75 Irssi::signal_stop(); 76 } elsif ($text =~ /Notice -- Temporary K-line for \[(.*)\] expired/) { 77 print_warning_expired($1, $dest->{tag}); 78 } elsif ($text =~ /Notice -- (.*)!.*@.*{.*} has removed the K-Line for: \[(.*)\]/) { 79 print_warning_unkline($1, $2, $dest->{tag}); 80 } elsif ($text =~ /K-Line for \[(.*)\] is removed/) { 81 Irssi::signal_stop(); 82 } 83} 84 85sub print_warning_kline { 86 87 my ($nick, $host, $network) = @_; 88 my $signalstop; 89 90 $signalstop = Irssi::settings_get_bool('show_kline_snote'); 91 92 if ($signalstop == 0) { 93 Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'kline_added', $nick, $host, $network); 94 Irssi::signal_stop(); 95 } else { 96 Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'kline_added', $nick, $host, $network); 97 } 98} 99 100sub print_warning_tkline { 101 102 my ($nick, $duration, $host, $network) = @_; 103 my $signalstop; 104 105 $signalstop = Irssi::settings_get_bool('show_kline_snote'); 106 107 if ($signalstop == 0) { 108 Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'tkline_added', $nick, $duration, $host, $network); 109 Irssi::signal_stop(); 110 } else { 111 Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'tkline_added', $nick, $duration, $host, $network); 112 } 113} 114 115sub print_warning_expired { 116 117 my ($host, $network) = @_; 118 my $signalstop; 119 120 $signalstop = Irssi::settings_get_bool('show_kline_snote'); 121 122 if ($signalstop == 0) { 123 Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'expired', $host, $network); 124 Irssi::signal_stop(); 125 } else { 126 Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'expired', $host, $network); 127 } 128} 129 130sub print_warning_unkline { 131 132 my ($nick, $host , $network) = @_; 133 my $signalstop; 134 135 $signalstop = Irssi::settings_get_bool('show_kline_snote'); 136 137 if ($signalstop == 0) { 138 Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'remove', $nick, $host, $network); 139 Irssi::signal_stop(); 140 } else { 141 Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'remove', $nick, $host, $network); 142 } 143} 144 145Irssi::signal_add_first('server event', 'kline_warning'); 146Irssi::settings_add_bool('warning', 'show_kline_snote' => 0); 147Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'kline_warning_loaded', $IRSSI{name}, $VERSION, $IRSSI{authors}); 148