html/invitejoin.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.01";
  28 
  29 %IRSSI = (
  30     authors     => 'Geert Hauwaerts',
  31     contact     => 'geert@irssi.org',
  32     name        => 'invitejoin.pl',
  33     description => 'This script will join a channel if somebody invites you to it.',
  34     license     => 'Public Domain',
  35     url         => 'http://irssi.hauwaerts.be/invitejoin.pl',
  36     changed     => 'Sun Apr 11 12:38:18 2004',
  37 );
  38 
  39 ## Comments and remarks.
  40 #
  41 # This script uses settings.
  42 # Use /SET to change the value or /TOGGLE to switch it on or off.
  43 #
  44 #    Setting:     invitejoin
  45 #    Description: If this setting is turned on, you will join the channel
  46 #                 when invite to.
  47 #
  48 ##
  49 
  50 
  51 Irssi::theme_register([
  52     'invitejoin_loaded', '%R>>%n %_Scriptinfo:%_ Loaded $0 version $1 by $2.',
  53     'invitejoin_invited', '%R>>%n %_Invitejoin:%_ Joined $1 (Invited by $0).'
  54 ]);
  55 
  56 sub invitejoin {
  57     
  58     my ($server, $channel, $nick, $address) = @_;
  59     my $invitejoin = Irssi::settings_get_bool('invitejoin');
  60 
  61     if ($invitejoin) {
  62         $server->command("join $channel");
  63         
  64         Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'invitejoin_invited', $nick, $channel);
  65         Irssi::signal_stop();
  66     }
  67 }
  68 
  69 Irssi::signal_add('message invite', 'invitejoin');
  70 
  71 Irssi::settings_add_bool('invitejoin', 'invitejoin' => 1);
  72 
  73 Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'invitejoin_loaded', $IRSSI{name}, $VERSION, $IRSSI{authors});