From 8a79d430aef83402420b5a8378e78cfa01051c93 Mon Sep 17 00:00:00 2001 From: dms Date: Thu, 21 Nov 2002 13:33:44 +0000 Subject: [PATCH] - strictify - remove old if statement involing useStrict. git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@659 c11ca15a-4712-0410-83d8-924469b57eb5 --- src/Factoids/Core.pl | 6 +++++- src/Factoids/DBCommon.pl | 2 +- src/Factoids/Norm.pl | 2 +- src/Factoids/Reply.pl | 2 +- src/Factoids/Statement.pl | 2 +- src/Factoids/Update.pl | 2 +- src/Files.pl | 6 +++++- src/IRC/Irc.pl | 19 +++++++++++++++---- src/IRC/Schedulers.pl | 4 ++-- src/Modules/Dict.pl | 11 +++++++---- src/Modules/DumpVars2.pl | 3 ++- src/Modules/Math.pl | 4 +++- src/Modules/News.pl | 12 +++++++++--- src/Modules/RootWarn.pl | 5 ++++- src/Modules/Topic.pl | 4 ++-- src/Modules/Units.pl | 2 ++ src/Modules/Uptime.pl | 2 +- src/Modules/Zippy.pl | 2 ++ src/Modules/insult.pl | 4 ++-- src/Modules/zfi.pl | 6 ++++-- src/Modules/zsi.pl | 6 ++++-- src/Net.pl | 6 ++++-- src/Process.pl | 20 +++++++++++++++----- src/Shm.pl | 4 +++- src/UserExtra.pl | 10 ++++++---- src/interface.pl | 3 +-- 26 files changed, 103 insertions(+), 46 deletions(-) diff --git a/src/Factoids/Core.pl b/src/Factoids/Core.pl index 0d4b6db..e288157 100644 --- a/src/Factoids/Core.pl +++ b/src/Factoids/Core.pl @@ -5,7 +5,11 @@ # Created: 20010906 # -if (&IsParam("useStrict")) { use strict; } +# use strict; # TODO + +use vars qw(%param %cache %lang %cmdstats %bots); +use vars qw($message $who $addressed $chan $h $nuh $ident $msgType + $correction_plausable); # Usage: &validFactoid($lhs,$rhs); sub validFactoid { diff --git a/src/Factoids/DBCommon.pl b/src/Factoids/DBCommon.pl index 178847d..709fd41 100644 --- a/src/Factoids/DBCommon.pl +++ b/src/Factoids/DBCommon.pl @@ -5,7 +5,7 @@ # Created: 19991020 # -if (&IsParam("useStrict")) { use strict; } +# use strict; # TODO ##### # Usage: &setFactInfo($faqtoid, $key, $val); diff --git a/src/Factoids/Norm.pl b/src/Factoids/Norm.pl index 4ce2ba0..f673102 100644 --- a/src/Factoids/Norm.pl +++ b/src/Factoids/Norm.pl @@ -4,7 +4,7 @@ # Version: 1997 # -if (&IsParam("useStrict")) { use strict; } +# use strict; # TODO sub normquery { my ($in) = @_; diff --git a/src/Factoids/Reply.pl b/src/Factoids/Reply.pl index 14f516a..4ba2135 100644 --- a/src/Factoids/Reply.pl +++ b/src/Factoids/Reply.pl @@ -10,7 +10,7 @@ # rhs - factoid message. ## -if (&IsParam("useStrict")) { use strict; } +# use strict; # TODO use vars qw($msgType $uh $lastWho $ident); use vars qw(%lang %lastWho); diff --git a/src/Factoids/Statement.pl b/src/Factoids/Statement.pl index aec268c..f689fc8 100644 --- a/src/Factoids/Statement.pl +++ b/src/Factoids/Statement.pl @@ -13,7 +13,7 @@ ## - null for confused. ## -if (&IsParam("useStrict")) { use strict; } +# use strict; # TODO sub doStatement { my($in) = @_; diff --git a/src/Factoids/Update.pl b/src/Factoids/Update.pl index 7811bb7..8855382 100644 --- a/src/Factoids/Update.pl +++ b/src/Factoids/Update.pl @@ -6,7 +6,7 @@ # Created: 1997 # -if (&IsParam("useStrict")) { use strict; } +# use strict; # TODO sub update { my($lhs, $mhs, $rhs) = @_; diff --git a/src/Files.pl b/src/Files.pl index d51cecd..75c52a1 100644 --- a/src/Files.pl +++ b/src/Files.pl @@ -5,7 +5,11 @@ # Created: 19991221 # -#use strict; +use strict; + +use vars qw(%lang %ircPort); +use vars qw(@ircServers); +use vars qw($bot_config_dir); # File: Language support. sub loadLang { diff --git a/src/IRC/Irc.pl b/src/IRC/Irc.pl index a5a90ca..b6eb283 100644 --- a/src/IRC/Irc.pl +++ b/src/IRC/Irc.pl @@ -5,10 +5,16 @@ # NOTE: Based on code by Kevin Lenzo & Patrick Cole (c) 1997 # -if (&IsParam("useStrict")) { use strict; } +use strict; -use vars qw($nickserv); -$nickserv = 0; +use vars qw(%floodjoin %nuh %dcc %cache %channels %param %mask + %chanconf %orig %ircPort %ircstats %last %netsplit); +use vars qw($irc $nickserv $ident $conn $msgType $who $talkchannel + $addressed); +use vars qw($notcount $nottime $notsize $msgcount $msgtime $msgsize + $pubcount $pubtime $pubsize); +use vars qw($b_blue $ob); +use vars qw(@joinchan @ircServers); # static scalar variables. $mask{ip} = '(\d+)\.(\d+)\.(\d+)\.(\d+)'; @@ -19,6 +25,8 @@ my $isnick2 = '0-9\-'; $mask{nick} = "[$isnick1]{1}[$isnick1$isnick2]*"; $mask{nuh} = '\S*!\S*\@\S*'; +$nickserv = 0; + sub ircloop { my $error = 0; my $lastrun = 0; @@ -636,7 +644,7 @@ sub invite { # Usage: &joinNextChan(); sub joinNextChan { if (scalar @joinchan) { - $chan = shift @joinchan; + my $chan = shift @joinchan; &joinchan($chan); if (my $i = scalar @joinchan) { @@ -707,6 +715,7 @@ sub IsNickInChan { sub IsNickInAnyChan { my ($nick) = @_; + my $chan; foreach $chan (keys %channels) { next unless (grep /^\Q$nick\E$/i, keys %{ $channels{$chan}{''} }); @@ -812,10 +821,12 @@ sub getJoinChans { sub closeDCC { # &DEBUG("closeDCC called."); + my $type; foreach $type (keys %dcc) { next if ($type ne uc($type)); + my $nick; foreach $nick (keys %{ $dcc{$type} }) { next unless (defined $nick); &status("DCC CHAT: closing DCC $type to $nick."); diff --git a/src/IRC/Schedulers.pl b/src/IRC/Schedulers.pl index b801a2a..18360d8 100644 --- a/src/IRC/Schedulers.pl +++ b/src/IRC/Schedulers.pl @@ -5,7 +5,7 @@ # Created: 20000117 # -if (&IsParam("useStrict")) { use strict; } +# use strict; # TODO use POSIX qw(strftime); use vars qw(%sched); @@ -41,10 +41,10 @@ sub setupSchedulers { &factoidCheck(2); # takes a couple of seconds on a 486. defer it &newsFlush(1); + # todo: squeeze this into a one-liner. # my $count = map { exists $sched{$_}{TIME} } keys %sched; my $count = 0; foreach (keys %sched) { -# next unless (exists $sched{$_}{TIME}); my $time = $sched{$_}{TIME}; next unless (defined $time and $time > time()); diff --git a/src/Modules/Dict.pl b/src/Modules/Dict.pl index b055299..9c49a5b 100644 --- a/src/Modules/Dict.pl +++ b/src/Modules/Dict.pl @@ -10,16 +10,18 @@ package Dict; use IO::Socket; use strict; +#use vars qw(PF_INET); + my $server = "dict.org"; # need a specific host||ip. -my $port = 2628; -my $proto = getprotobyname('tcp'); ###local $SIG{ALRM} = sub { die "alarm\n" }; sub Dict { my ($query) = @_; -### return unless &::loadPerlModule("IO::Socket"); - my $socket = new IO::Socket; +# return unless &::loadPerlModule("IO::Socket"); + my $socket = new IO::Socket; + my $port = 2628; + my $proto = getprotobyname('tcp'); my @results; for ($query) { @@ -29,6 +31,7 @@ sub Dict { } # connect. +# TODO: make strict-safe constants... so we can defer IO::Socket load. socket($socket, PF_INET, SOCK_STREAM, $proto) or return "error: socket: $!"; eval { alarm 10; diff --git a/src/Modules/DumpVars2.pl b/src/Modules/DumpVars2.pl index f507396..eb81433 100644 --- a/src/Modules/DumpVars2.pl +++ b/src/Modules/DumpVars2.pl @@ -5,7 +5,8 @@ # Created: 20020329 # -#use strict; +# use strict; # TODO + use Devel::Symdump; sub symdumplog { diff --git a/src/Modules/Math.pl b/src/Modules/Math.pl index caecf9f..1e23177 100644 --- a/src/Modules/Math.pl +++ b/src/Modules/Math.pl @@ -2,7 +2,9 @@ # infobot copyright (C) kevin lenzo 1997-98 # -if (&IsParam("useStrict")) { use strict; } +use strict; + +use vars qw($message); my %digits = ( "first", "1", diff --git a/src/Modules/News.pl b/src/Modules/News.pl index 419dfb8..1c1629d 100644 --- a/src/Modules/News.pl +++ b/src/Modules/News.pl @@ -15,10 +15,12 @@ # Text - Actual text. ### -use vars qw($who $chan); - package News; +use strict; + +use vars qw($who $chan); + sub Parse { my($what) = @_; $chan = undef; @@ -225,6 +227,7 @@ sub writeNews { $c = scalar keys %{ $::news{$chan} }; next unless ($c); $cc++; + my $item; foreach $item (sort keys %{ $::news{$chan} }) { $c = scalar keys %{ $::news{$chan}{$item} }; @@ -232,6 +235,7 @@ sub writeNews { $ci++; print NEWS "$chan $item\n"; + my $what; foreach $what (sort keys %{ $::news{$chan}{$item} }) { print NEWS " $what: $::news{$chan}{$item}{$what}\n"; } @@ -393,7 +397,9 @@ sub list { $newest = $t if ($t > $newest); if ($e > 1 and $e < $expire) { $expire = $e; - $eno = &newsS2N($item); + &::DEBUG("before newsS2N($_)"); + $eno = &newsS2N($_); + &::DEBUG("after newsS2N($_) == $eno"); } } my $timestr = &::Time2String(time() - $newest); diff --git a/src/Modules/RootWarn.pl b/src/Modules/RootWarn.pl index 086cac5..cb3d967 100644 --- a/src/Modules/RootWarn.pl +++ b/src/Modules/RootWarn.pl @@ -5,7 +5,10 @@ # Created: 19991008 # -### use strict; +use strict; + +use vars qw(%channels %param); +use vars qw($dbh $found $ident); sub rootWarn { my ($nick,$user,$host,$chan) = @_; diff --git a/src/Modules/Topic.pl b/src/Modules/Topic.pl index 4e7e9aa..2778fee 100644 --- a/src/Modules/Topic.pl +++ b/src/Modules/Topic.pl @@ -6,8 +6,8 @@ # use strict; -use vars qw(%topiccmp); -no strict "refs"; ### FIXME!!! +use vars qw(%topiccmp %topic %channels %orig); +use vars qw($who $chan $conn $uh $ident); ############################### ##### INTERNAL FUNCTIONS diff --git a/src/Modules/Units.pl b/src/Modules/Units.pl index c24ea42..bc7be77 100644 --- a/src/Modules/Units.pl +++ b/src/Modules/Units.pl @@ -5,6 +5,8 @@ package Units; +# use strict; # TODO + #$DEBUG_p = 1; #$DEBUG_o = 1; #$DEBUG_l = 1; diff --git a/src/Modules/Uptime.pl b/src/Modules/Uptime.pl index ca2e584..d433952 100644 --- a/src/Modules/Uptime.pl +++ b/src/Modules/Uptime.pl @@ -5,7 +5,7 @@ # Created: 19990925. # -# use strict; +# use strict; # TODO my $uptimerecords = 3; diff --git a/src/Modules/Zippy.pl b/src/Modules/Zippy.pl index e082791..73f4d63 100644 --- a/src/Modules/Zippy.pl +++ b/src/Modules/Zippy.pl @@ -7,6 +7,8 @@ package zippy; +use strict; + my $no_zippy; # Can't think of any situation in which this won't work.. sub zippy::get { diff --git a/src/Modules/insult.pl b/src/Modules/insult.pl index e139791..be37b91 100644 --- a/src/Modules/insult.pl +++ b/src/Modules/insult.pl @@ -4,10 +4,10 @@ # => use the command hooks system aswell # -use strict; - package Insult; +use strict; + sub Insult { my ($insultwho) = @_; return unless &::loadPerlModule("Net::Telnet"); diff --git a/src/Modules/zfi.pl b/src/Modules/zfi.pl index de77352..0d4ed64 100644 --- a/src/Modules/zfi.pl +++ b/src/Modules/zfi.pl @@ -24,6 +24,8 @@ package zfi; # We reply publicly or privately, depending how we were called +use strict; + my $no_zfi; BEGIN { @@ -43,7 +45,7 @@ sub queryText { my $res_return = 5; my $ua = new LWP::UserAgent; - $ua->proxy('http', $::param{'httpProxy'}) if (&::IsParam("httpProxy")); + $ua->proxy('http', $::param{'httpProxy'}) if (&::IsParam("httpProxy")); $ua->timeout(10); @@ -95,7 +97,7 @@ sub queryText { sub query { my ($args) = @_; &::performStrictReply(&queryText($args)); - return; + return; } 1; diff --git a/src/Modules/zsi.pl b/src/Modules/zsi.pl index c1eb692..6a4a82e 100644 --- a/src/Modules/zsi.pl +++ b/src/Modules/zsi.pl @@ -26,6 +26,8 @@ package zsi; my $no_zsi; +use strict; + BEGIN { $no_zsi = 0; eval "use LWP::UserAgent"; @@ -43,7 +45,7 @@ sub queryText { my $res_return = 5; my $ua = new LWP::UserAgent; - $ua->proxy('http', $::param{'httpProxy'}) if (&::IsParam("httpProxy")); + $ua->proxy('http', $::param{'httpProxy'}) if (&::IsParam("httpProxy")); $ua->timeout(10); @@ -95,7 +97,7 @@ sub queryText { sub query { my ($args) = @_; &::performStrictReply(&queryText($args)); - return; + return; } 1; diff --git a/src/Net.pl b/src/Net.pl index 083d62b..306e20a 100644 --- a/src/Net.pl +++ b/src/Net.pl @@ -5,8 +5,9 @@ # Created: 20000309 # -#use strict; -use vars qw(%ftp); +use strict; + +use vars qw(%ftp %param); # Usage: &ftpGet($host,$dir,$file,[$lfile]); sub ftpGet { @@ -144,6 +145,7 @@ sub ftpList { ### LWP. # Usage: &getURL($url, [$post]); +# todo: rename this to getHTTP sub getURL { my ($url,$post) = @_; my ($ua,$res,$req); diff --git a/src/Process.pl b/src/Process.pl index 05f297b..75499a2 100644 --- a/src/Process.pl +++ b/src/Process.pl @@ -6,7 +6,13 @@ # process the incoming message # -#use strict; +use strict; + +use vars qw($who $msgType $addressed $message $ident $user $host $chan + $learnok $talkok $force_public_reply $noreply $addrchar + $literal $addressedother $userHandle $lobotomized); +use vars qw(%channels %users %param %cache %chanconf %mask %orig %lang + ); sub process { $learnok = 0; # Able to learn? @@ -292,6 +298,9 @@ sub process { # karma. set... if ($message =~ /^(\S+)(--|\+\+)\s*$/ and $addressed) { return '' unless (&hasParam("karma")); + # well... since it is policy to do bot functions before factoids + # karma gets hit if, for example, "g++" is issued. + # only way to request it is to put a question mark at the end. my($term,$inc) = (lc $1,$2); @@ -305,8 +314,8 @@ sub process { return; } - my $karma = &dbGet("stats", "counter", "nick=".&dbQuote($term). - " AND type='karma'") || 0; + my $karma = &dbGet("stats", "counter", + "nick=".&dbQuote($term)." AND type='karma'") || 0; if ($inc eq '++') { $karma++; } else { @@ -314,8 +323,9 @@ sub process { } &dbSet("stats", - { nick => $term, type => "karma" }, - { counter => $karma } + { nick => $term, type => "karma" }, # WHERE +# { counter => $karma } # WHAT + { -counter => "counter+1" } ); return; diff --git a/src/Shm.pl b/src/Shm.pl index 41f96bf..5ab3d18 100644 --- a/src/Shm.pl +++ b/src/Shm.pl @@ -5,6 +5,8 @@ # Created: 20000124 # +# use strict; # TODO + use POSIX qw(_exit); sub openSHM { @@ -12,7 +14,7 @@ sub openSHM { my $size = 2000; if (&IsParam("noSHM")) { - &status("Created shared memory: disabled. [bot may become unreliable]"); + &status("Shared memory: Disabled. WARNING: bot may become unreliable"); return 0; } diff --git a/src/UserExtra.pl b/src/UserExtra.pl index 895d8cb..50f00e6 100644 --- a/src/UserExtra.pl +++ b/src/UserExtra.pl @@ -5,9 +5,11 @@ # Created: 20000107 # -#use strict; -use vars qw($message $arg $qWord $verb $lobotomized); -use vars qw(%channels %chanstats %cmdstats); +use strict; +use vars qw($message $arg $qWord $verb $lobotomized $who $result $chan + $conn $msgType $query $talkchannel $ident $memusage); +use vars qw(%channels %chanstats %cmdstats %count %ircstats %param + %cache %mask %userstats %hooks_main); ### ### Start of command hooks for UserExtra. @@ -18,7 +20,7 @@ use vars qw(%channels %chanstats %cmdstats); &addCmdHook("main", 'factinfo', ('CODEREF' => 'factinfo', 'Cmdstats' => 'Factoid Info', Module => 'factoids', ) ); &addCmdHook("main", 'factstats?', ('CODEREF' => 'factstats', - 'Cmdstats' => 'Factoid Statistics', Help => "factstats", + 'Cmdstats' => 'Factoid Stats', Help => "factstats", Forker => 1, 'Identifier' => 'factoids', ) ); &addCmdHook("main", 'help', ('CODEREF' => 'help', 'Cmdstats' => 'Help', ) ); diff --git a/src/interface.pl b/src/interface.pl index 036691a..c94e926 100644 --- a/src/interface.pl +++ b/src/interface.pl @@ -1,10 +1,9 @@ # # interface.pl: -# # Author: # -#use strict; +# use strict; # TODO sub whatInterface { if (!&IsParam("Interface") or $param{'Interface'} =~ /IRC/) { -- 2.39.2