html/iraident.pl


   1 #!/usr/bin/perl
   2 
   3 # This is for NickServ Russian Ircnet services
   4 # just edit $ident_name and $password
   5 # 
   6 # tested on irc.nov.ru
   7 # todo:
   8 # - before quote codepage will be great to check current
   9 # - notify from nickserv may has a different text
  10 
  11 
  12 use strict;
  13 use Irssi;
  14 
  15 use vars qw($VERSION %IRSSI);                                                                                 
  16                                                                                                               
  17 $VERSION = "0.6.1";                                                                                        
  18 %IRSSI = (                                                                                                    
  19     authors     => "DonRumata",                                                                 
  20     contact     => "rumata\@dragons.ru",                                                                    
  21     name        => "iraident",                                                                                
  22     description => "IrcNet.ru Auto Identify - changes nick and send identify command, then sets codepage",                                                      
  23     license     => "GPLv2",                                                                                   
  24     url         => "http://rumata.dragons.ru",                                                                                        
  25     changed     => "$VERSION",                                                                                
  26     commands    => "none"                                                                                     
  27 );
  28 
  29 
  30 my $ident_name = "DonRumata_for_example";
  31 my $password   = "some_identify_string";
  32 #my $fmt = MSGLEVEL_CLIENTNOTICES;
  33 
  34 sub server_event_catch {
  35     # $server = server record where the message came                                                      
  36     # $data = the raw data received from server, with PRIVMSGs it is:                                     
  37     #         "target :text" where target is either your nick or #channel                                 
  38     # $nick = the nick who sent the message                                                               
  39     # $host = host of the nick who sent the message
  40 
  41     my ($server, $text, $nick, $user) = @_;
  42 
  43     if (($nick == 'NickServ') and ($user == 'Services@ircnet.ru')){
  44 	# events:
  45 	# Nick is registered or protected or not registered
  46 
  47 	if ( $text =~ /your nick will be changed/){
  48 	    
  49 	    if ($server->{'nick'} ne $ident_name){
  50 		$server->command("NICK $ident_name");
  51 #		Irssi::print("ident string sent...",$fmt);
  52 		return;
  53 	    }
  54 
  55 	    return if ($server->{'usermode'} =~ /(r)/);
  56 	    $server->command("MSG NickServ identify $password");
  57 #	    Irssi::print("password sent",$fmt);
  58 
  59 	    $server->command("QUOTE codepage koi8");
  60 #	    Irssi::print("codepage sent",$fmt);
  61 	}
  62     }    
  63 }
  64 
  65 Irssi::signal_add('server event', 'server_event_catch');