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 = "0.06"; 28 29%IRSSI = ( 30 authors => 'Geert Hauwaerts', 31 contact => 'geert@irssi.org', 32 name => 'default.pl', 33 description => 'This script will filter some Freenode IRCD (Dancer) servernotices.', 34 license => 'GNU General Public License', 35 url => 'http://irssi.hauwaerts.be/freenode_filter.pl', 36 changed => 'Wed Sep 17 23:00:11 CEST 2003', 37); 38 39Irssi::theme_register([ 40 'window_missing', '%_Warning%_: %R>>%n You are missing the %_FILTER%_ window. Use %_/WINDOW NEW HIDDEN%_ and %_/WINDOW NAME FILTER%_ to create it.', 41 'filter', '{servernotice $0} $1', 42 'freenode_filter_loaded', '%R>>%n %_Scriptinfo:%_ Loaded $0 version $1 by $2.' 43]); 44 45sub check_filter { 46 47 if (!Irssi::window_find_name("FILTER")) { 48 Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'window_missing'); 49 return 0; 50 } 51 52 return 1; 53} 54 55sub parse_snote { 56 57 my ($dest, $text) = @_; 58 59 return if (($text !~ /^NOTICE/)); 60 61 if ($text =~ /Notice -- Client connecting:/) { 62 filter_snote($dest, $text); 63 } elsif ($text =~ /Notice -- Illegal nick/) { 64 filter_snote($dest, $text); 65 } elsif ($text =~ /Notice -- Invalid username:/) { 66 filter_snote($dest, $text); 67 } elsif ($text =~ /Notice -- X-line Warning/) { 68 filter_snote($dest, $text); 69 } elsif ($text =~ /Notice -- Kick from/) { 70 filter_snote($dest, $text); 71 } elsif ($text =~ /Notice -- Client exiting:/) { 72 filter_snote($dest, $text); 73 } elsif ($text =~ /Notice -- (.*) confirms kill/) { 74 filter_snote($dest, $text); 75 } elsif ($text =~ /Notice -- Remove from/) { 76 filter_snote($dest, $text); 77 } elsif ($text =~ /Notice -- Flooder (.*)/) { 78 filter_snote($dest, $text); 79 } elsif ($text =~ /Notice -- Received KILL message for/) { 80 filter_snote($dest, $text); 81 } 82 83 if ($text =~ /Notice -- (.*) has removed the K-Line for:/) { 84 active_snote($dest, $text); 85 } elsif ($text =~ /Notice -- (.*) added K-Line for/) { 86 active_snote($dest, $text); 87 } 88} 89 90sub filter_snote { 91 92 my ($server, $snote) = @_; 93 my $win = Irssi::window_find_name("FILTER"); 94 my $ownnick = $server->{nick}; 95 96 $snote =~ s/^NOTICE $ownnick ://; 97 98 if (!check_filter()) { 99 Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'window_missing'); 100 return; 101 } 102 103 $win->printformat(MSGLEVEL_SNOTES, 'filter', $server->{real_address}, $snote); 104 Irssi::signal_stop(); 105} 106 107sub active_snote { 108 109 my ($server, $snote) = @_; 110 my $ownnick = $server->{nick}; 111 my $win = Irssi::active_win(); 112 113 $snote =~ s/^NOTICE $ownnick ://; 114 115 $win->printformat(MSGLEVEL_SNOTES, 'filter', $server->{real_address}, $snote); 116 Irssi::signal_stop(); 117} 118 119check_filter(); 120 121Irssi::signal_add_first('server event', 'parse_snote'); 122Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'freenode_filter_loaded', $IRSSI{name}, $VERSION, $IRSSI{authors}); 123