html/hignore.pl


   1 #!/usr/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 
  23 use strict;
  24 use Irssi;
  25 use vars qw($VERSION %IRSSI);
  26 
  27 $VERSION = "0.02";
  28 
  29 %IRSSI = (
  30     authors     => 'Geert Hauwaerts',
  31     contact     => 'geert@irssi.org',
  32     name        => 'hignore.pl',
  33     description => 'This script will add the HIGNORE command, if you use this command in a query it will ignore the host.',
  34     license     => 'Public Domain',
  35     url         => 'http://irssi.hauwaerts.be/hignore.pl',
  36     changed     => 'Wed Sep 17 23:51:38 CEST 2003',
  37 );
  38 
  39 ## Comments and remarks.
  40 #
  41 # A little tip for this script.
  42 #
  43 #    Tip:     This script if verry usefull if you bind this to an F-key. For example if you get flooded
  44 #             (by the little bastard dj_poison on Undernet) you'll just need to press F1 and it will 
  45 #             ignore the hostmask and close the query.
  46 #    Command: /BIND meta2-P key F1
  47 #             /BIND F1 command eval hignore ; unquery
  48 #
  49 ##
  50 
  51 Irssi::theme_register([
  52     'loaded', '%R>>%n %_Scriptinfo:%_ Loaded $0 version $1 by $2.',
  53     'no_query', '%R>>%n %_HIGNORE:%_ The specified window isn\'t a query.',
  54     'no_host', '%R>>%n %_HIGNORE:%_ The specified query doesn\'t contain host information.'
  55 ]);
  56 
  57 sub hignore {
  58 
  59     my $wintype = Irssi::active_win->{active}->{type};
  60     my $winaddr = Irssi::active_win->{active}->{address};
  61 
  62     if ($wintype ne "QUERY") {
  63         Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'no_query');
  64     } else {
  65         if ($winaddr =~ /\b~?(.{1,10})@([a-zA-Z0-9_.-]+)\b/) {
  66             my ($user, $host) = ($1, $2);
  67             
  68             Irssi::command("IGNORE *!*\@$host");
  69         
  70         } else {
  71             Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'no_host');
  72         }
  73     }
  74 }
  75 
  76 Irssi::command_bind('hignore', 'hignore');
  77 
  78 Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'loaded', $IRSSI{name}, $VERSION, $IRSSI{authors});