This script automatically responds to identification requests by NickServ.
It uses a BerkeleyDB database to store passwords.
I have a small BDB application almost ready to edit the database.
The script is still unfinished, expect the one or the other problem…
Grab the code here, or take a look at the source:
1: # identify.pl 2: # 3: # Identify to NickServ automatically 4: # 5: # Copyright (c) 2007 - 2010 Szymon 'polemon' Bereziak <polemon@polemon.org> 6: # 7: # set nick_active, nick_inactive and idle_time to your needs 8: # This script is licensed untder ISC License 9: # 10: 11: use strict; 12: use vars qw($VERSION %IRSSI); 13: 14: use 5.010; 15: use Irssi; 16: use Data::Dumper; 17: use BerkeleyDB; 18: 19: $VERSION = "0.01"; 20: 21: %IRSSI = ( 22: author => "Szymon 'polemon' Bereziak", 23: contact => "polemon\@polemon.org", 24: name => "identify", 25: description => "automatically identify for nick", 26: license => "ISC", 27: url => "", 28: changed => "2010-10-13", 29: ); 30: 31: # add signals 32: Irssi::signal_add_first('message private', 'mesg'); 33: Irssi::signal_add_first('message irc notice', 'mesg'); 34: 35: # add command 36: Irssi::command_bind('ghost', 'c_ghost'); 37: Irssi::command_bind('login', 'c_login'); 38: 39: # we received a private message... 40: sub mesg { 41: my ($server, $msg, $nick, $adress) = @_; 42: 43: if($nick =~ /^nickserv$/i) { 44: # TODO see how adress can be used 45: if($msg =~ /nick(name)?.*registered/) { 46: $server->command("MSG $nick IDENTIFY " . &getpass($server)); 47: } 48: } 49: } 50: 51: # read password 52: sub getpass { 53: my ($serv) = @_; 54: my $val = ""; 55: my $db = new BerkeleyDB::Hash(-Filename => "$ENV{HOME}/.irssi/identify.db") or die "Cannot open database\n"; 56: 57: if($db->db_get($serv->{'chatnet'}, $val) == 0) { 58: return $val; 59: } 60: else { 61: return ""; 62: } 63: } 64: 65: # reclaim nickname 66: sub c_ghost { 67: my ($data, $server, $witem) = @_; 68: $server->command("MSG NickServ ghost " . $data . " " . &getpass($server)); 69: } 70: 71: sub c_login { 72: my ($data, $server, $witem) = @_; 73: $server->command("MSG NickServ identify " . &getpass($server)); 74: }
The script is by far and large automatized.
/ghost/loginnone (?)
The database file has to be in ~/.irssi/identify.db and it doesn't support encrypted databases yet. I'll change that some time.