diff options
| author | David Leadbeater | 2015-01-10 17:50:12 +0000 |
|---|---|---|
| committer | David Leadbeater | 2015-01-10 17:50:12 +0000 |
| commit | 3350aef6b04f0d33ad52b41179c6742a98d2aa1f (patch) | |
| tree | 287ac1dba07509317309acab3161f5da286958e9 | |
| parent | 1bae3cffef57d4d46d0230aa4f44cc52c7671b93 (diff) | |
| parent | 2d920d6f610e176bf121f9089f21956595df70e9 (diff) | |
| download | scripts.irssi.org-3350aef6b04f0d33ad52b41179c6742a98d2aa1f.tar.bz2 | |
Merge branch 'obfuscoder-perlcritic-e-l' into gh-pages
42 files changed, 175 insertions, 132 deletions
diff --git a/scripts/emaildb1.0.pl b/scripts/emaildb1.0.pl index 11ac906..bf661f2 100644 --- a/scripts/emaildb1.0.pl +++ b/scripts/emaildb1.0.pl @@ -49,7 +49,7 @@ # ... That's about it, enjoy! # - +use strict; use Irssi; use DBI; use vars qw($VERSION %IRSSI); @@ -71,9 +71,9 @@ $VERSION = "1.0"; # chomp( @user = <LIST> ); # close LIST; -$d = ('database'); -$u = ('user'); -$p = ('password'); +my $d = ('database'); +my $u = ('user'); +my $p = ('password'); sub event_privmsg { @@ -87,18 +87,18 @@ my ($target, $text) = $data =~ /^(\S*)\s:(.*)/; my ($nickname) = $text =~ /^~search (.*)/; - $dbh = DBI->connect("DBI:mysql:$d","$u","$p") + my $dbh = DBI->connect("DBI:mysql:$d","$u","$p") or die "Couldn't connect to database: " . DBI->errstr; - $sth = $dbh->prepare("SELECT * FROM 13th where nickname like \"\%$nickname\%\";") - or die "Cant prepare $statement: $dbh->errstr\n"; - $rv = $sth->execute + my $sth = $dbh->prepare("SELECT * FROM 13th where nickname like \"\%$nickname\%\";") + or die "Cant prepare statement: $dbh->errstr\n"; + my $rv = $sth->execute or die "cant execute the query: $sth->errstr\n"; if ($rv >= 1) { my @row; while ( @row = $sth->fetchrow_array( ) ) { - $n = "$row[0]\n"; - $e = "$row[1]\n"; - $b = "$row[2]\n"; + my $n = "$row[0]\n"; + my $e = "$row[1]\n"; + my $b = "$row[2]\n"; $server->command ( "msg $nick Nickname : $n" ); $server->command ( "msg $nick Email : $e" ); $server->command ( "msg $nick Birthday : $b" ); diff --git a/scripts/exec_clean.pl b/scripts/exec_clean.pl index 7405ef6..766627f 100644 --- a/scripts/exec_clean.pl +++ b/scripts/exec_clean.pl @@ -1,6 +1,8 @@ # $Id: exec-clean.pl,v 1.6 2002/07/04 13:18:02 jylefort Exp $ +use strict; use Irssi 20020121.2020 (); +use vars qw($VERSION %IRSSI); $VERSION = "1.01"; %IRSSI = ( authors => 'Jean-Yves Lefort', @@ -32,7 +34,6 @@ $VERSION = "1.01"; # # * kill the process using a better method (TERM -> sleep -> KILL etc) -use strict; use Irssi::UI; sub window_destroyed { diff --git a/scripts/extaway.pl b/scripts/extaway.pl index 78e8392..cc1a495 100644 --- a/scripts/extaway.pl +++ b/scripts/extaway.pl @@ -35,7 +35,7 @@ my ($oldnick, $t_away); sub init { # verifying if settings file exists - if (!(open xa_settings, "<$xa_confile")) { + if (!(open xa_settings, q{<}, $xa_confile)) { putlog("No config file: /xahelp for help"); return 0; }; @@ -135,7 +135,7 @@ sub xa_add { # Adding the keyword and the reason in the config file # may create double entries... my($kw, $reason) = @_; - if(!(open xa_settings, ">>$xa_confile")) { + if(!(open xa_settings, q{>>}, $xa_confile)) { &putlog("Unable to open file $xa_confile"); } print xa_settings "$kw:$reason\n"; @@ -146,7 +146,7 @@ sub xa_add { sub xa_save { # save the temp infos (might correct the double entries) my ($data,$server,$channel) = @_; - if(!(open xa_settings, ">$xa_confile")) { + if(!(open xa_settings, q{>}, $xa_confile)) { &putlog("Unable to create file $xa_confile"); } print xa_settings "bnick:$infos{'bnick'}\n"; diff --git a/scripts/fakectcp.pl b/scripts/fakectcp.pl index d86ceab..cc80a9b 100644 --- a/scripts/fakectcp.pl +++ b/scripts/fakectcp.pl @@ -139,7 +139,7 @@ sub load_fakectcplist { if (-e $file) { local *F; - open(F, "<$file"); + open(F, "<", $file); local $/ = "\n"; while (<F>) { @@ -162,7 +162,7 @@ sub save_fakectcplist { my ($file) = @_; local *F; - open(F, ">$file") or die "Could not load the fake ctcpreply list for writing"; + open(F, ">", $file) or die "Could not load the fake ctcpreply list for writing"; for (my $n = 0; $n < @fakectcp; ++$n) { print(F join("\t", $fakectcp[$n]->{item}, $fakectcp[$n]->{reply}) . "\n"); diff --git a/scripts/file.pl b/scripts/file.pl index c088561..95c573e 100644 --- a/scripts/file.pl +++ b/scripts/file.pl @@ -1,3 +1,5 @@ +use strict; +use vars qw($VERSION %IRSSI); my $help = <<EOF; Usage: (all on one line) @@ -26,8 +28,6 @@ $VERSION = 1.0; url => "http://irssi.dgl.cx/" ); -use strict; - Irssi::command_bind('file', sub { my $data = shift; @@ -64,7 +64,7 @@ Irssi::command_bind('file', sub { } # or do borrowed from one of juerd's scripts (needs 5.6 though) - open(FILE, "<$data") or do { + open(FILE, "<", $data) or do { print "Error opening '$data': $!"; return; }; diff --git a/scripts/find.pl b/scripts/find.pl index 0b9a77f..507975e 100644 --- a/scripts/find.pl +++ b/scripts/find.pl @@ -1,6 +1,7 @@ # /FIND - display people who are in more than one channel with you # (it's ugly code) +use strict; use Irssi; use vars qw($VERSION %IRSSI); diff --git a/scripts/findbot.pl b/scripts/findbot.pl index 9f79259..fdddfe0 100644 --- a/scripts/findbot.pl +++ b/scripts/findbot.pl @@ -347,9 +347,9 @@ sub debugprint { $win->set_name($IRSSI{name}); # Select the window $win->print($debugmessage,MSGLEVEL_CLIENTCRAP); my $debugtid = localtime(time); - open (LOGFILE,">> $logfile"); - print LOGFILE "$debugtid: $debugmessage\n"; - close (LOGFILE); + open (LOGFILE,">>", $logfile); + print LOGFILE "$debugtid: $debugmessage\n"; + close (LOGFILE); } } @@ -583,7 +583,7 @@ sub admin_activesends { sub admin_reload { if ( -r Irssi::settings_get_str('findbot_summaryfile') ) { - open (FINDFILE,Irssi::settings_get_str('findbot_summaryfile')); # Open the file + open (FINDFILE, "<", Irssi::settings_get_str('findbot_summaryfile')); # Open the file @bigarray = <FINDFILE>; # Load it whole into memory :) close (FINDFILE); debugprint(10,"[ADMIN] Summary file has been reloaded into memory."); @@ -841,7 +841,7 @@ Irssi::command_bind('findbotactivesends', 'admin_activesends'); check_vital_configuration(); # Run a subroutine to check all variables before starting if ( -r Irssi::settings_get_str('findbot_summaryfile') ) { - open (FINDFILE,Irssi::settings_get_str('findbot_summaryfile')); # Open the file + open (FINDFILE, "<", Irssi::settings_get_str('findbot_summaryfile')); # Open the file @bigarray = <FINDFILE>; # Load it whole into memory :) close (FINDFILE); } else { diff --git a/scripts/fleech.pl b/scripts/fleech.pl index 3443c28..935d803 100644 --- a/scripts/fleech.pl +++ b/scripts/fleech.pl @@ -744,7 +744,7 @@ sub print_dbg { my ($txt, $mlvl) = @_; my $lvl = Irssi::settings_get_int('fleech_verbose_level'); if ($dbglog) { - if (not open (DBGLOG, ">> $dbglog")) { + if (not open (DBGLOG, ">>", $dbglog)) { $dbglog = ""; } else { # print_dbg("fleech.pl $VERSION loaded"); diff --git a/scripts/friends_peder.pl b/scripts/friends_peder.pl index bc4355b..fffa9eb 100644 --- a/scripts/friends_peder.pl +++ b/scripts/friends_peder.pl @@ -56,7 +56,7 @@ sub load_friends { local(*FILE); %friends = (); - open FILE, "< $file"; + open FILE, "<", $file; while (<FILE>) { ($mask,$net,$channel,$flags) = split; for (split //, $flags) { @@ -81,7 +81,7 @@ sub save_friends { return if $auto && !Irssi::settings_get_bool('friends_autosave'); - open FILE, "> $file"; + open FILE, ">", $file; for my $mask (keys %friends) { $count++; for my $net (keys %{$friends{$mask}}) { diff --git a/scripts/friends_shasta.pl b/scripts/friends_shasta.pl index dae5590..f05dd1a 100644 --- a/scripts/friends_shasta.pl +++ b/scripts/friends_shasta.pl @@ -832,7 +832,7 @@ sub load_friends { $all_handles = {}; local *F; - open(F, "<$friendfile") or return -1; + open(F, "<", $friendfile) or return -1; local $/ = "\n"; while (<F>) { my ($handle, $hosts, $globflags, $chanstr, $password, $comment); @@ -913,7 +913,7 @@ sub save_friends { # be sane my $old_umask = umask(077); - if (!defined open(F, ">$tmpfile")) { + if (!defined open(F, ">", $tmpfile)) { Irssi::print("Couldn't open $tmpfile for writing"); return 0; } diff --git a/scripts/fserve.pl b/scripts/fserve.pl index 607f91c..0fdc350 100644 --- a/scripts/fserve.pl +++ b/scripts/fserve.pl @@ -591,7 +591,7 @@ sub sig_dcc_connected if ($motdfile_modified < $lm) { $motdfile_modified = $lm; @motd = (); - open(FILE, $f); + open(FILE, "<", $f); while(<FILE>) { chomp; s/\t/ /g; @@ -2937,7 +2937,7 @@ sub display_file ($$) { return; } - unless (open (RFILE, $filepath)) { + unless (open (RFILE, "<", $filepath)) { send_user_msg($server_tag, $irc_nick, "Couldn't open file: " . "'$fs_prefs{clr_hi}$ufile$fs_prefs{clr_txt}'!"); print_msg("Could not open file $filepath"); @@ -3263,7 +3263,7 @@ sub save_config { my $f = $conffile; $f =~ s/\$IRSSI/Irssi::get_irssi_dir()/e or $f =~ s/~/$ENV{"HOME"}/; - if (!open(FILE, ">$f")) { + if (!open(FILE, ">", $f)) { print_msg("Unable to open $f for writing!"); return 1; } @@ -3301,7 +3301,7 @@ sub save_config ############################################################################### sub load_distro { my $file = $_[0]; - if (!open(FILE, "<$file")) { + if (!open(FILE, "<", $file)) { print_msg("Unable to open $file for reading!"); return 0; } @@ -3336,7 +3336,7 @@ sub save_distro my $f = $fs_prefs{distro_file}; $f =~ s/\$IRSSI/Irssi::get_irssi_dir()/e or $f =~ s/~/$ENV{"HOME"}/; - if (!open(FILE, ">$f")) { + if (!open(FILE, ">", $f)) { print_msg("Unable to open $f for writing!"); return 1; } @@ -3359,7 +3359,7 @@ sub load_config my $f = $conffile; $f =~ s/\$IRSSI/Irssi::get_irssi_dir()/e or $f =~ s/~/$ENV{"HOME"}/; - if (!open(FILE, "<$f")) { + if (!open(FILE, "<", $f)) { print_msg("Unable to open $f for reading!"); return 1; } @@ -3418,7 +3418,7 @@ sub save_queue my $f = $fs_prefs{queuefile}; $f =~ s/\$IRSSI/Irssi::get_irssi_dir()/e or $f =~ s/~/$ENV{"HOME"}/; - if (!open(FILE, ">$f")) { + if (!open(FILE, ">", $f)) { print_msg("Unable to open $f for writing!"); return 1; } @@ -3468,7 +3468,7 @@ sub load_queue my $f = $fs_prefs{queuefile}; $f =~ s/\$IRSSI/Irssi::get_irssi_dir()/e or $f =~ s/~/$ENV{"HOME"}/; - if (!open(FILE, "<$f")) { + if (!open(FILE, "<", $f)) { print_msg("Unable to open $f for reading!"); return 1; } @@ -3565,7 +3565,7 @@ sub print_log { my $f = $fs_prefs{log_name}; $f =~ s/\$IRSSI/Irssi::get_irssi_dir()/e or $f =~ s/~/$ENV{"HOME"}/; - if (!$logfp && $fs_prefs{log_name} && open(LOGFP, ">>$f")) { + if (!$logfp && $fs_prefs{log_name} && open(LOGFP, ">>", $f)) { $logfp = \*LOGFP; select((select($logfp), $|++)[0]); } diff --git a/scripts/getop.pl b/scripts/getop.pl index 1dbd75c..4b1914c 100644 --- a/scripts/getop.pl +++ b/scripts/getop.pl @@ -343,7 +343,7 @@ sub channel_sync { sub savegetop { local *fp; - open (fp, ">$getopfile") or die "Couldn't open $getopfile for writing"; + open (fp, ">", $getopfile) or die "Couldn't open $getopfile for writing"; for my $ircnet (keys %getop) { for my $chan (keys %{$getop{$ircnet}}) { @@ -361,7 +361,7 @@ sub loadgetop { return unless (-e $getopfile); local *fp; - open (fp, "<$getopfile") or die "Couldn't open $getopfile for reading"; + open (fp, "<", $getopfile) or die "Couldn't open $getopfile for reading"; local $/ = "\n"; while (<fp>) { diff --git a/scripts/gimmie.pl b/scripts/gimmie.pl index f04f964..df0102d 100644 --- a/scripts/gimmie.pl +++ b/scripts/gimmie.pl @@ -1,3 +1,4 @@ +use strict; use Irssi; use vars qw($VERSION %IRSSI); diff --git a/scripts/grep.pl b/scripts/grep.pl index 976d867..35ce15c 100644 --- a/scripts/grep.pl +++ b/scripts/grep.pl @@ -57,7 +57,7 @@ sub cmd_grep { $cmd = join(' ',@args); # check if the regexp is valid - eval("'' =~ /$match/"); + eval { qr/$match/ }; if($@) { # there was an error chomp $@; Irssi::print($@,MSGLEVEL_CLIENTERROR); diff --git a/scripts/hilightwin.pl b/scripts/hilightwin.pl index f7af8a7..cb54ef2 100644 --- a/scripts/hilightwin.pl +++ b/scripts/hilightwin.pl @@ -6,6 +6,7 @@ # window (can be toggled) and to put up a timestamp. # +use strict; use Irssi; use POSIX; use vars qw($VERSION %IRSSI); @@ -34,7 +35,7 @@ sub sig_printtext { ($dest->{level} & ($opt)) && ($dest->{level} & MSGLEVEL_NOHILIGHT) == 0 ) { - $window = Irssi::window_find_name('hilight'); + my $window = Irssi::window_find_name('hilight'); if ($dest->{level} & MSGLEVEL_PUBLIC) { $text = $dest->{target}.": ".$text; @@ -47,7 +48,7 @@ sub sig_printtext { } } -$window = Irssi::window_find_name('hilight'); +my $window = Irssi::window_find_name('hilight'); Irssi::print("Create a window named 'hilight'") if (!$window); Irssi::settings_add_bool('hilightwin','hilightwin_showprivmsg',1); diff --git a/scripts/hitcount.pl b/scripts/hitcount.pl index 3af36e1..545aee0 100644 --- a/scripts/hitcount.pl +++ b/scripts/hitcount.pl @@ -1,5 +1,6 @@ # $Id: hitcount.pl,v 1.3.2.2 2002/03/05 18:19:28 shrike Exp shrike $ +use strict; use vars qw($VERSION %IRSSI); my @rev = split(/ /, "$Revision: 1.3.2.2 $n"); $VERSION = "1.3"; @@ -49,7 +50,6 @@ $VERSION = "1.3"; # Add ignore regexp, to prevent f.ex. css-files from increasing counter use Irssi::TextUI; -use strict; # Debug level - higher levels print out more crap my $debug_level = 0; @@ -73,7 +73,7 @@ sub get_hitcount { ($total_hitcount, $my_hitcount) = (0); # Go through the access log and count matches to the given regexp - if(open STUFF, "$filename") + if(open STUFF, "<", $filename) { while (<STUFF>) { diff --git a/scripts/hl.pl b/scripts/hl.pl index 3c28cd9..7fd898d 100644 --- a/scripts/hl.pl +++ b/scripts/hl.pl @@ -1,5 +1,6 @@ # CopyLeft Riku Voipio 2001 # half-life bot script +use strict; use Irssi; use Irssi::Irc; use vars qw($VERSION %IRSSI); @@ -17,23 +18,23 @@ $VERSION = "1.2"; ); -$qdir="/home/nchip/qstat/"; +my $qdir="/home/nchip/qstat/"; sub cmd_hl { my ($server, $data, $nick, $mask, $target) =@_; if ($data=~/^!hl/){ - @foo=split(/\s+/,$data); - $len=@foo; + my @foo=split(/\s+/,$data); + my $len=@foo; if ($len==1){ $foo[1]="turpasauna.taikatech.com"; } #fixme, haxxor protection - $word=$foo[1]; + my $word=$foo[1]; $_=$word; $word=~s/[^a-zA-ZäöÄÖ0-9\.]/ /g; - open(DAT, "$qdir"."qstat -hls ".$word."|"); - $count=0; - foreach $line (<DAT>) + open(DAT, "-|", $qdir."qstat -hls $word"); + my $count=0; + foreach my $line (<DAT>) { if ($count==1) { @@ -50,5 +51,3 @@ sub cmd_hl { Irssi::signal_add_last('message public', 'cmd_hl'); Irssi::print("Half-life info bot by nchip loaded."); - - diff --git a/scripts/hlbot.pl b/scripts/hlbot.pl index a51e34c..d9e5113 100644 --- a/scripts/hlbot.pl +++ b/scripts/hlbot.pl @@ -32,7 +32,7 @@ # ## - +use strict; use Socket; use Sys::Hostname; use IO::Handle; @@ -78,10 +78,11 @@ my $log_on = 1; sub run_bot { my $server = Irssi::active_server(); + my $msg; - ($hispaddr = recv(S, $msg, 1000, 0)) or print "$!\n"; - ($port, $hisiaddr) = sockaddr_in($hispaddr); - $host = inet_ntoa($hisiaddr); + (my $hispaddr = recv(S, $msg, 1000, 0)) or print "$!\n"; + my ($port, $hisiaddr) = sockaddr_in($hispaddr); + my $host = inet_ntoa($hisiaddr); $msg =~ s/\n.$//s; $msg =~ s/\n..$//s; @@ -113,7 +114,7 @@ sub run_bot { # Received challenge rcon reply.. elsif ($msg =~ /^˙˙˙˙challenge rcon (\d+)$/ && $rcon_msg) { $challenge = $1; - $data = "˙˙˙˙rcon $challenge $rcon_pass $rcon_msg"; + my $data = "˙˙˙˙rcon $challenge $rcon_pass $rcon_msg"; defined(send(S, $data, 0, $serv_paddr)) or $server->command("/notice $channel Error sending rcon: $!"); } @@ -127,8 +128,8 @@ sub run_bot { # Multiline rcon responses if ($msg =~ /\n/s) { - @rows = split /\n/, $msg; - foreach $row (@rows) { + my @rows = split /\n/, $msg; + foreach my $row (@rows) { # We don't want to see these if ($row =~ /^[\t \n]*$/ || $row =~ /^[ADMIN] Load/ || @@ -199,7 +200,7 @@ sub msg_command { #########[ MAIN ]########### # Open the logfile. -open LOG, ">>$logfile" or die "Cannot open logfile!\n"; +open LOG, ">>", $logfile or die "Cannot open logfile!\n"; LOG->autoflush(1); # Start listening the socket for udp messages. diff --git a/scripts/hostname.pl b/scripts/hostname.pl index 8871aea..2dc23bf 100644 --- a/scripts/hostname.pl +++ b/scripts/hostname.pl @@ -1,6 +1,8 @@ # $Id: hostname.pl,v 1.8 2002/07/04 13:18:02 jylefort Exp $ +use strict; use Irssi 20020121.2020 (); +use vars qw($VERSION %IRSSI); $VERSION = "1.01"; %IRSSI = ( authors => 'Jean-Yves Lefort', @@ -96,7 +98,6 @@ $VERSION = "1.01"; # # 2002-02-01 initial release -use strict; use Socket; use Socket6; @@ -116,7 +117,7 @@ sub hostname { sub get_addresses { Irssi::print("Resolving IP addresses..."); %addresses = (); - open(IFCONFIG, "ifconfig|"); + open(IFCONFIG, "-|", "ifconfig"); while (<IFCONFIG>) { $addresses{$2} = resolve($2) if (/(inet addr:|inet6 addr: |inet |inet6 )([0-9a-f.:]*)/ diff --git a/scripts/iMPD.pl b/scripts/iMPD.pl index 945a1bf..6078e55 100644 --- a/scripts/iMPD.pl +++ b/scripts/iMPD.pl @@ -262,7 +262,7 @@ sub addShufflePlay { sub cleanup { my ($file) = Irssi::get_irssi_dir."/iMPD.conf"; - open CONF, "> $file"; + open CONF, ">", $file; for my $net (sort keys %SAVE_VARS) { print CONF "$net\t$SAVE_VARS{$net}\n"; close CONF; @@ -489,7 +489,7 @@ print $mpd_help_advanced; sub load_settings { my ($file) = Irssi::get_irssi_dir."/iMPD.conf"; - open CONF, "< $file"; + open CONF, "<", $file; while (<CONF>) { my($net,$val) = split; if ($net && $val) { diff --git a/scripts/ignore_log.pl b/scripts/ignore_log.pl index 77f3c0f..38c1ca1 100644 --- a/scripts/ignore_log.pl +++ b/scripts/ignore_log.pl @@ -59,7 +59,7 @@ sub write_log { my ($nick, $msg, $tgt) = @_ ; $tgt ||= "->" ; my ($lfile) = glob Irssi::settings_get_str("ignore_log"); - if (open(LF, ">>$lfile")) { + if (open(LF, ">>", $lfile)) { my $ts = strftime("%D %H:%M", localtime()) ; print LF "[$ts] $tgt $nick $msg\n" ; close LF ; diff --git a/scripts/ignoreoc.pl b/scripts/ignoreoc.pl index de5d86c..776b3d7 100644 --- a/scripts/ignoreoc.pl +++ b/scripts/ignoreoc.pl @@ -1,4 +1,5 @@ #!/usr/bin/perl -w +use strict; use Irssi; use vars qw($VERSION %IRSSI); $VERSION = "0.6"; diff --git a/scripts/intjoin.pl b/scripts/intjoin.pl index c9660e0..858ae25 100644 --- a/scripts/intjoin.pl +++ b/scripts/intjoin.pl @@ -4,6 +4,7 @@ # - http://penguin-breeder.org/irssi/ #<scriptinfo> +use strict; use vars qw($VERSION %IRSSI); use Irssi 20020120; @@ -35,12 +36,12 @@ sub cmd_join18n { return; } - $enc = Irssi::settings_get_str("join18n_encoding"); + my $enc = Irssi::settings_get_str("join18n_encoding"); $enc = $1 if $data =~ /^\s*-enc\s+(\S+)/; $data =~ s/^\s*-enc\s+(\S+)//; - $converter = Text::Iconv->new("UTF-8", $enc); + my $converter = Text::Iconv->new("UTF-8", $enc); if (!$converter) { Irssi::print("Invalid encoding specified: $enc"); @@ -63,14 +64,14 @@ sub cmd_msg18n { return; } - $name = $channel->{name}; + my $name = $channel->{name}; - $enc = Irssi::settings_get_str("join18n_encoding"); + my $enc = Irssi::settings_get_str("join18n_encoding"); $enc = $1 if $data =~ /^\s*-enc\s+(\S+)/; $data =~ s/^\s*-enc\s+(\S+)//; - $converter = Text::Iconv->new("UTF-8", $enc); + my $converter = Text::Iconv->new("UTF-8", $enc); if (!$converter) { Irssi::print("Invalid encoding specified: $enc"); @@ -94,14 +95,14 @@ sub cmd_part18n { return; } - $name = $channel->{name}; + my $name = $channel->{name}; - $enc = Irssi::settings_get_str("join18n_encoding"); + my $enc = Irssi::settings_get_str("join18n_encoding"); $enc = $1 if $data =~ /^\s*-enc\s+(\S+)/; $data =~ s/^\s*-enc\s+(\S+)//; - $converter = Text::Iconv->new("UTF-8", $enc); + my $converter = Text::Iconv->new("UTF-8", $enc); if (!$converter) { Irssi::print("Invalid encoding specified: $enc"); diff --git a/scripts/irc_chess.pl b/scripts/irc_chess.pl index 3c46e8a..a8f8ef5 100644 --- a/scripts/irc_chess.pl +++ b/scripts/irc_chess.pl @@ -1,6 +1,7 @@ # #Irssi script to complement chess backend server # +use strict; use Irssi; use Irssi::Irc; use IO::Socket; @@ -16,6 +17,7 @@ $VERSION="0.1"; license => "GNU GPL", url => "none as yet", ); +my $gameRunning=0; sub processColors { @@ -63,12 +65,12 @@ sub processColors # sub processMsgFromServer { - ($server, $msg, $nick)=@_; - $delimiter="<:=:>"; + my ($server, $msg, $nick)=@_; + my $delimiter="<:=:>"; $_=$msg; #determine the type of message from the number of delimiters - $numDelims=(@list=/$delimiter/g); + my $numDelims=(my @list=/$delimiter/g); if ($numDelims==0) { @@ -113,7 +115,7 @@ sub processMsgFromServer my @msg1List=split(/\n/, $msg1); my $msg1ListSize=@msg1List; - for ($j=0; $j<$msg1ListSize; $j++) + for (my $j=0; $j<$msg1ListSize; $j++) { $server->command("eval msg $user1 \\cb$msg1List[$j]\\co"); } @@ -121,7 +123,7 @@ sub processMsgFromServer my @msg2List=split(/\n/, $msg2); my $msg2ListSize=@msg2List; - for ($j=0; $j<$msg2ListSize; $j++) + for (my $j=0; $j<$msg2ListSize; $j++) { $server->command("eval msg $user2 \\cb$msg2List[$j]\\co"); } @@ -141,7 +143,7 @@ sub processMsgFromServer sub processMsgFromClient { - ($server, $msg, $nick)=@_; + my ($server, $msg, $nick)=@_; #Irssi::print("msg from client:\n$msg\n"); $msg=lc($msg); @@ -166,13 +168,14 @@ sub sig_processPvt { my($server, $msg, $nick, $address)=@_; - $msgToSend=processMsgFromClient($server, $msg, $nick); + my $msgToSend=processMsgFromClient($server, $msg, $nick); if ($msgToSend !~ /^INVALID$/) { Irssi::print("Sending message now"); send(SOCKET,$msgToSend,0); Irssi::print("Waiting for message from server\n"); + my $buffer; recv(SOCKET,$buffer,32678,0); #read a max of 32k. processMsgFromServer($server, $buffer, $nick); } @@ -192,15 +195,15 @@ sub cmd_endGame BEGIN { - $PORT=1234; + my $PORT=1234; Irssi::print("connecting to server\n"); - $tcpProtocolNumber = getprotobyname('tcp') || 6; + my $tcpProtocolNumber = getprotobyname('tcp') || 6; socket(SOCKET, PF_INET(), SOCK_STREAM(), $tcpProtocolNumber) or die("socket: $!"); - $internetPackedAddress = pack('S na4 x8', AF_INET(), $PORT, 127.0.0.1); + my $internetPackedAddress = pack('S na4 x8', AF_INET(), $PORT, 127.0.0.1); connect(SOCKET, $internetPackedAddress) or die("connect: $!"); Irssi::print("Game is now running"); diff --git a/scripts/irccomplete.pl b/scripts/irccomplete.pl index bac2de1..d2ac527 100644 --- a/scripts/irccomplete.pl +++ b/scripts/irccomplete.pl @@ -2,6 +2,7 @@ # for irssi 0.7.99 by Timo Sirainen # Greatly modified by Erkki Seppälä to build dictionary of said words +use strict; use Irssi; use vars qw($VERSION %IRSSI); @@ -66,11 +67,13 @@ sub sig_complete { if (exists $typoWords{$word}) { my $correctWord = $correctWordsByIndex{$typoWords{$word}->[0]}->[0]; - @$complist = (@complist, $correctWord); + @$complist = (@$complist, $correctWord); } + my $n; my %m = map { ($_ => $n++); } @$complist; @$complist = (); + my %m2; foreach my $key (sort keys %m) { $m2{$m{$key}}=$key; } diff --git a/scripts/ircgallery.pl b/scripts/ircgallery.pl index 38b48ff..c044a45 100644 --- a/scripts/ircgallery.pl +++ b/scripts/ircgallery.pl @@ -3,6 +3,7 @@ # version 1.13 # for irssi 0.8.0 by Timo Sirainen +use strict; use Symbol; use vars qw($VERSION %IRSSI); $VERSION = "1.13"; @@ -13,7 +14,7 @@ $VERSION = "1.13"; description => "Show IRC gallery (http://irc-galleria.net, finnish only) information on /WHOIS or /GALLERY", license => "Public Domain", url => "http://irssi.org/", - changed => "2002-03-04T22:47+0100"
+ changed => "2002-03-04T22:47+0100" ); @@ -42,6 +43,7 @@ sub get_view_url { # print the gallery information - assumes the file is in cache directory sub print_gallery { + my %print_notfound; my $nick = shift; my $found = 0; @@ -50,7 +52,7 @@ sub print_gallery { $. = "\n"; my $f = gensym; - if (!open($f, "$cache_path/$nick")) { + if (!open($f, "<", "$cache_path/$nick")) { Irssi::print("Couldn't open file $cache_path/$nick: $!", MSGLEVEL_CLIENTERROR); return; } @@ -204,7 +206,7 @@ sub parse_nicks { $gallery_nicks_time = time(); my $f = gensym; - if (!open($f, $filename)) { + if (!open($f, "<", $filename)) { Irssi::print("Couldn't open file $filename: $!", MSGLEVEL_CLIENTERROR); return; } @@ -243,7 +245,7 @@ sub download_nicklist { if (-d $cache_path) { unlink(<$cache_path/*>); } else { - mkdir($cache_path, 0700) || die "Can't create cache directory $cache_dir"; + mkdir($cache_path, 0700) || die "Can't create cache directory $cache_path"; } # we need the nick list, get it once per hour diff --git a/scripts/ircgmessagenotify.pl b/scripts/ircgmessagenotify.pl index a614282..e3973bd 100644 --- a/scripts/ircgmessagenotify.pl +++ b/scripts/ircgmessagenotify.pl @@ -17,6 +17,7 @@ # Kiitokset statusbar ideasta Whiz:ille.. kiitos pällistä ideasta pälliin skriptaan jne. # Kiitoksia ei heru Whizille kylläkään toimimattomista regexpeistä... joutu ihan itse opetteleen keletanatu. +use strict; use LWP::UserAgent; use HTTP::Cookies; use Irssi; diff --git a/scripts/irssiBlaster.pl b/scripts/irssiBlaster.pl index 0897a87..6d06a30 100644 --- a/scripts/irssiBlaster.pl +++ b/scripts/irssiBlaster.pl @@ -85,7 +85,7 @@ # - use strict; ################################################################################# -#use strict; +use strict; use Irssi; use Irssi::TextUI; use vars qw($VERSION %IRSSI); @@ -100,13 +100,15 @@ $VERSION = '1.6'; changed => 'Fri Oct 31 12:22:08 CET 2003', ); - +# TODO get rid of all those globals. This script needs some serious rework. +my (@all, @artist, @title, @album, @year, @name, @status, @comment, @mode, @format, @bitrate, @samplerate, @length, @next, @tot); +my ($name, $infofile, $status, $artist, $title, $year, $album, $comment, $format, $bitrate, $mode, $samplerate, $length, $next, $min, $sec, $secs, $prefix, $barprefix, $tot); sub get_info { my $infofile = Irssi::settings_get_str('blaster_infos_path'); - open (FILE, $infofile); # open and read file with infos - @all = <FILE>; + open (FILE, "<", $infofile); # open and read file with infos + my @all = <FILE>; close (FILE); @artist = grep (/^artist/, @all); # get the lines with tag infos @@ -119,8 +121,8 @@ sub get_info { sub get_allinfo { - my $infofile = Irssi::settings_get_str('blaster_infos_path'); - open (FILE, $infofile); + $infofile = Irssi::settings_get_str('blaster_infos_path'); + open (FILE, "<", $infofile); @all = <FILE>; close (FILE); @@ -181,8 +183,8 @@ sub get_allinfo { sub get_status { - my $infofile = Irssi::settings_get_str('blaster_infos_path'); - open (FILE, $infofile); + $infofile = Irssi::settings_get_str('blaster_infos_path'); + open (FILE, "<", $infofile); @all = <FILE>; close (FILE); @@ -225,7 +227,7 @@ sub get_name_info { sub noinfo_error { - my $infofile = Irssi::settings_get_str('blaster_infos_path'); + $infofile = Irssi::settings_get_str('blaster_infos_path'); # print help if the info file is not valid Irssi::print( "%9IrssiBlaster:%_ \"$infofile\" is not a valid info file. %9Make sure%_ %Rmp3blaster -f $infofile%n %9is running!!!%_\n". diff --git a/scripts/isdn.pl b/scripts/isdn.pl index b429ec7..b1ceed8 100644 --- a/scripts/isdn.pl +++ b/scripts/isdn.pl @@ -8,6 +8,7 @@ # Script now runs for several days without any # problems. Added documentation. +use strict; use Irssi; use vars qw($VERSION %IRSSI); $VERSION = "0.3"; @@ -20,9 +21,11 @@ $VERSION = "0.3"; changed => "Thu Jun 17 12:49:55 CEST 2004", ); +my $timer; + sub incoming_call() # triggered by a timer; use of input_add { # caused crash - while ($message = <ISDNLOG>) + while (my $message = <ISDNLOG>) { chomp($message); if ($message =~ / Call to tei .* RING/) # just incoming calls @@ -40,7 +43,7 @@ sub incoming_call() # triggered by a timer; use of input_add sub isdn_unload() # for a clean unload { - close $ISDNLOG; + close ISDNLOG; Irssi::timeout_remove($timer); } diff --git a/scripts/kblamehost.pl b/scripts/kblamehost.pl index d53fe78..86e4e23 100644 --- a/scripts/kblamehost.pl +++ b/scripts/kblamehost.pl @@ -1,7 +1,9 @@ #!/usr/bin/perl +use strict; use Irssi; use Irssi::Irc; +use vars qw($VERSION %IRSSI); $VERSION = "0.0.1"; %IRSSI = ( @@ -45,7 +47,7 @@ sub event_join # hostname, but array counts from 0 so element's count is number of dots my $is_friend = 0; - foreach $exclude (@excludes) + foreach my $exclude (@excludes) { $is_friend = 1 if ($hostname =~ $exclude); } diff --git a/scripts/keepnick.pl b/scripts/keepnick.pl index 181dc23..5027ef1 100644 --- a/scripts/keepnick.pl +++ b/scripts/keepnick.pl @@ -81,7 +81,7 @@ sub load_nicks { local(*CONF); %keepnick = (); - open CONF, "< $file"; + open CONF, "<", $file; while (<CONF>) { my($net,$nick) = split; if ($net && $nick) { @@ -105,7 +105,7 @@ sub save_nicks { return if $auto && !Irssi::settings_get_bool('keepnick_autosave'); - open CONF, "> $file"; + open CONF, ">", $file; for my $net (sort keys %keepnick) { print CONF "$net\t$keepnick{$net}\n"; $count++; diff --git a/scripts/kill_fake_gets.pl b/scripts/kill_fake_gets.pl index 65be5b4..0eefb40 100644 --- a/scripts/kill_fake_gets.pl +++ b/scripts/kill_fake_gets.pl @@ -12,6 +12,9 @@ # Anyway, this should be fixed. And now it closes stalled gets as well. # +use strict; +use vars qw($VERSION %IRSSI); + $VERSION = "1.1"; %IRSSI = ( authors => "Piotr 'Cvbge' Krukowiecki", @@ -28,7 +31,7 @@ my $debug = 0; # set this to 1 to enable A LOT OF debug messages sub pd { return if (not $debug); - $dcc = @_[0]; + my $dcc = @_[0]; Irssi::print("SDC '$dcc->{type}' from '$dcc->{nick}' on '$dcc->{servertag}' arg '$dcc->{arg}'"); Irssi::print("SDC created '$dcc->{created}' addr '$dcc->{addr}' port '$dcc->{port}'"); Irssi::print("SDC starttime '$dcc->{starttime}' transfd '$dcc->{transfd}'"); diff --git a/scripts/kills.pl b/scripts/kills.pl index 7ed2d53..50d9383 100644 --- a/scripts/kills.pl +++ b/scripts/kills.pl @@ -10,6 +10,7 @@ # There's a pretty good explanation of (ircnet) ircd's server kills in # http://www.irc.org/tech_docs/ircnet/kills.html +use strict; use Irssi; use vars qw($VERSION %IRSSI); @@ -47,13 +48,13 @@ sub msg_quit { my @printargs = (); if ($killmsg =~ /([^ ]*) != (.*)/) { # 1 != 2 - my $server1 = $1, $server2 = $2; + my $server1 = $1, my $server2 = $2; $server1 =~ s/([^\[]*)\[([^\]]*)\]/\1/; $msg .= "$2 != $server2"; } elsif ($killmsg =~ /([^ ]*) <- (.*)/) { # 1 <- 2 - my $server1 = $1, $server2 = $2; + my $server1 = $1, my $server2 = $2; if ($server1 =~ /^\(/) { # (addr1)server1 <- (add2)server2 @@ -84,9 +85,9 @@ sub msg_quit { $msg = $killmsg; } - @list = $server->nicks_get_same($nick); + my @list = $server->nicks_get_same($nick); while (@list) { - $channel = $list[0]; + my $channel = $list[0]; shift @list; # skip nick record shift @list; diff --git a/scripts/lastfm.pl b/scripts/lastfm.pl index 4ff2105..77ec944 100644 --- a/scripts/lastfm.pl +++ b/scripts/lastfm.pl @@ -1,4 +1,5 @@ # vim: set expandtab: +use strict; use vars qw($VERSION %IRSSI); $VERSION = "5.8"; %IRSSI = ( @@ -240,7 +241,6 @@ sub DEBUG { Irssi::settings_get_bool("lastfm_debug"); }; -use strict; use warnings; no warnings 'closure'; use Data::Dumper; diff --git a/scripts/lastspoke.pl b/scripts/lastspoke.pl index 6cabda7..063c4a9 100644 --- a/scripts/lastspoke.pl +++ b/scripts/lastspoke.pl @@ -20,8 +20,10 @@ # # Triggers on !lastspoke <nick>, !seen <nick> and !lastseen <nick> # +use strict; use Irssi; use Irssi::Irc; +use vars qw($VERSION %IRSSI); $VERSION = "0.2"; %IRSSI = ( @@ -33,6 +35,8 @@ $VERSION = "0.2"; url => 'http://irssi.freshdot.net/', ); +my $target; + # Storage for the data. my %lasthash; @@ -83,7 +87,7 @@ sub on_join { my ($server, $channel, $nick, $address) = @_; my $allowedChans = lc(Irssi::settings_get_str("lastspoke_channels")) || "(null)"; - if (index($allowedChans, $target) >= 0) { + if (index($allowedChans, $channel) >= 0) { $lasthash{lc($nick)}{'last'} = time(); $lasthash{lc($nick)}{'words'} = "$nick joined $channel"; } @@ -94,7 +98,7 @@ sub on_part { my ($server, $channel, $nick, $address, $reason) = @_; my $allowedChans = lc(Irssi::settings_get_str("lastspoke_channels")) || "(null)"; - if (index($allowedChans, $target) >= 0) { + if (index($allowedChans, $channel) >= 0) { $lasthash{lc($nick)}{'last'} = time(); if (! $reason) { $lasthash{lc($nick)}{'words'} = "$nick left from $channel with no reason"; @@ -107,9 +111,9 @@ sub on_part { # Hook for public messages. # Only act on channels we are supposed to act on (settings_get_str) sub on_public { - my ($server, $msg, $nick, $addr, $target) = @_; + my ($server, $msg, $nick, $addr, $_target) = @_; - $target = $nick if ( ! $target ); + $_target = $nick if ( ! $_target ); $nick = $server->{'nick'} if ($nick =~ /^#/); $target = lc($target); diff --git a/scripts/licq.pl b/scripts/licq.pl index cc7b1ec..92a83a1 100644 --- a/scripts/licq.pl +++ b/scripts/licq.pl @@ -1,3 +1,5 @@ +use strict; +use vars qw($VERSION %IRSSI); $VERSION = "0.5"; %IRSSI = ( authors => "Jari Matilainen", @@ -25,7 +27,7 @@ sub licq { my $filename = "$rdir" . "$_"; if(-e $filename) { - open(FILE, $filename); + open(FILE, "<", $filename); $_ = ""; $_ = <FILE> until /NewMessages/; my @total = split / /, $_; diff --git a/scripts/linkchan.pl b/scripts/linkchan.pl index 08476fa..34fb619 100644 --- a/scripts/linkchan.pl +++ b/scripts/linkchan.pl @@ -92,7 +92,7 @@ Irssi::command_bind "link list", sub sub save_config() { - open CONFIG, ">$config"; + open CONFIG, ">", $config; foreach my $chatnet1 (keys %links) { foreach my $channel1 (keys %{$links{$chatnet1}}) @@ -113,7 +113,7 @@ Irssi::signal_add "setup saved", sub sub load_config() { %links = (); - open CONFIG, $config or return; + open CONFIG, "<", $config or return; while (<CONFIG>) { chomp; diff --git a/scripts/listen.pl b/scripts/listen.pl index 13f2e14..9fd13ab 100644 --- a/scripts/listen.pl +++ b/scripts/listen.pl @@ -1,3 +1,4 @@ +use strict; use Irssi; use Irssi::Irc; @@ -37,7 +38,10 @@ $VERSION = "0.2"; # list of supported mp3 players # if you would like to use the script with other players, just type these # name into the list below... it will probably work :) -@mp3players=("mpg123", "mpg321", "xmms", "mp3blaster", "alsaplayer"); +my @mp3players=("mpg123", "mpg321", "xmms", "mp3blaster", "alsaplayer", "audacious"); +my ($mp3player, $mp3file); +my @line; +my %idtag; ################## PLZ DON'T CHANGE ANYTHING BELOW THIS LINE ################## # or do it on your own risk!! @@ -53,13 +57,13 @@ sub default_values { } sub getmp3filename { - open(CSOCS,$_[0]); + open(CSOCS, "-|", $_[0]); GECMO: while (<CSOCS>) { chop; (@line) = split(/\s/,$_); # we check wheter the mp3file returned by lsof has been opened # with a known mp3player or not - HMM: foreach $w (@mp3players) { + HMM: foreach my $w (@mp3players) { # if yes we save it, and leave if ($w =~ /^$line[0]/) { $mp3player=$w; @@ -79,10 +83,10 @@ sub getmp3filename { sub getmp3proces { # most of the players put the file into the memory at first, # let's try to catch it there, first - getmp3filename("/usr/sbin/lsof -d mem | grep -i .mp3|"); + getmp3filename("lsof -d mem | grep -i .mp3"); # if we didn't find anything there, we check the fds for mp3s if ($mp3player eq "nope") { - getmp3filename("/usr/sbin/lsof -d 1-15 | grep -i .mp3|"); + getmp3filename("lsof -d 1-15 | grep -i \\.mp3"); } # hmm are we listening to anything? @@ -103,10 +107,10 @@ sub getmp3proces { sub getmp3idtags { # getting the idtags from file - open(ID3GECMO, "/usr/bin/id3 -R -l \"$mp3file\" |"); + open(ID3GECMO, "-|", "id3 -R -l \"$mp3file\""); while (<ID3GECMO>) { chop; - foreach $kulcs (keys %idtag) { + foreach my $kulcs (keys %idtag) { if ($_=~ /^$kulcs/) { s/^$kulcs://; s/\s*$//; s/^\s*//; if ($_) { $idtag{$kulcs}=$_; } @@ -117,26 +121,26 @@ sub getmp3idtags { } sub do_listen { - #setting up variables my ($data, $server, $witem) = @_; default_values(); if (!getmp3proces()) { return }; getmp3idtags(); + my $outtext; # if there's no usable idtag in the mp3 we use the filename if (($idtag{"Artist"} eq "Unknow Artist") && ($idtag{"Title"} eq "Unknown Title")) { - $outtext=$mp3filename; + $outtext=$mp3file; } else { # if the file is tagged we parse over the tagorder $outtext=Irssi::settings_get_str("listen_tagorder"); - foreach $w (keys %idtag) { + foreach my $w (keys %idtag) { $outtext=~s/%$w/$idtag{$w}/i; } $outtext=~s/%player/$mp3player/i; } - $prefix=Irssi::settings_get_str("listen_prefix"); + my $prefix=Irssi::settings_get_str("listen_prefix"); if (Irssi::settings_get_bool("listen_use_action")) { $outtext="ME ".$prefix." ".$outtext; diff --git a/scripts/loadavg.pl b/scripts/loadavg.pl index 7ca4b45..e9509ed 100644 --- a/scripts/loadavg.pl +++ b/scripts/loadavg.pl @@ -4,7 +4,9 @@ # /statusbar window add loadavg # /set loadavg_refresh +use strict; use Irssi; +use Irssi::TextUI; use vars qw($VERSION %IRSSI); $VERSION="0.4"; @@ -16,6 +18,8 @@ $VERSION="0.4"; license => 'public domain', ); +my ($timeout, $lavg); + sub reload { Irssi::statusbar_items_redraw('loadavg'); } sub setup { diff --git a/scripts/logcompress.pl b/scripts/logcompress.pl index 6d41362..39089c1 100644 --- a/scripts/logcompress.pl +++ b/scripts/logcompress.pl @@ -1,5 +1,6 @@ # compress log files when they're rotated # for irssi 0.7.99 by Timo Sirainen +use strict; use Irssi; use vars qw($VERSION %IRSSI); $VERSION = "0.01"; @@ -10,7 +11,7 @@ $VERSION = "0.01"; description => "compress logfiles then they\'re rotated", license => "Public Domain", url => "http://irssi.org/", - changed => "2002-03-04T22:47+0100"
+ changed => "2002-03-04T22:47+0100" ); diff --git a/scripts/ls.pl b/scripts/ls.pl index 6481081..4bdce13 100644 --- a/scripts/ls.pl +++ b/scripts/ls.pl @@ -1,5 +1,5 @@ +use strict; use vars qw($VERSION %IRSSI); - use Irssi 20020120; $VERSION = "0.02"; %IRSSI = ( diff --git a/scripts/lwho.pl b/scripts/lwho.pl index 5a70079..a821f9e 100644 --- a/scripts/lwho.pl +++ b/scripts/lwho.pl @@ -1,7 +1,8 @@ # This script adds command /lwho that shows # locally logged users in current window - +use strict; +use vars qw($VERSION %IRSSI); $VERSION = '0.01a'; %IRSSI = ( authors => 'Mika', |
