1# RandName 1.0 2# 3# set a random real name taken from a file 4# 5# derived from quitmsg.pl by Timo Sirainen 6 7use strict; 8use Irssi; 9use vars qw($VERSION %IRSSI); 10 11$VERSION = '1.0'; 12%IRSSI = ( 13 authors => 'legion', 14 contact => 'a.lepore(at)email.it', 15 name => 'RandName', 16 description => 'Random "/set real_name" taken from a file.', 17 license => 'Public Domain', 18 changed => 'Sat Dec 6 12:28:04 CET 2003', 19); 20 21sub randname { 22 23 my $namefile = glob Irssi::settings_get_str('random_realname_file'); 24 25 open (FILE, "<", $namefile) || return; 26 my $lines = 0; while(<FILE>) { $lines++; }; 27 my $line = int(rand($lines))+1; 28 29 my $realname; 30 seek(FILE, 0, 0); $. = 0; 31 while(<FILE>) { 32 next if ($. != $line); 33 chomp; 34 $realname = $_; 35 last; 36 } 37 close(f); 38 39 Irssi::print("%9RandName.pl%_:", MSGLEVEL_CRAP); 40 Irssi::command("set real_name $realname"); 41 42} ## 43 44Irssi::signal_add('gui exit', 'randname'); 45Irssi::command_bind('randname', 'randname'); 46Irssi::settings_add_str('misc', 'random_realname_file', '~/.irssi/irssi.realnames'); 47