X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2FFiles.pl;h=3a294aae063c628a2fd3fb8c1c7eb23690cbf99a;hb=45e51047c2df703229843193e49fb9829489170f;hp=938f6155c7a7c087953a92dcbb524f79ff080b5c;hpb=3936a3e1255582305fc4200485b71fa692e66bd3;p=infobot.git diff --git a/src/Files.pl b/src/Files.pl index 938f615..3a294aa 100644 --- a/src/Files.pl +++ b/src/Files.pl @@ -17,33 +17,33 @@ sub loadLang { my $langCount = 0; my $replyName; - if (!open(FILE, $file)) { - &ERROR("Failed reading lang file ($file): $!"); - exit 0; + if ( !open( FILE, $file ) ) { + &ERROR("Failed reading lang file ($file): $!"); + exit 0; } - undef %lang; # for rehash. + undef %lang; # for rehash. while () { - chop; - if ($_ eq '' || /^#/) { - undef $replyName; - next; - } - - if (!/^\s/) { - $replyName = $_; - next; - } - - s/^[\s\t]+//g; - if (!$replyName) { - &status("loadLang: bad line ('$_')"); - next; - } - - $lang{$replyName}{$_} = 1; - $langCount++; + chop; + if ( $_ eq '' || /^#/ ) { + undef $replyName; + next; + } + + if ( !/^\s/ ) { + $replyName = $_; + next; + } + + s/^[\s\t]+//g; + if ( !$replyName ) { + &status("loadLang: bad line ('$_')"); + next; + } + + $lang{$replyName}{$_} = 1; + $langCount++; } close FILE; @@ -53,31 +53,34 @@ sub loadLang { # File: Irc Servers list. sub loadIRCServers { - my ($file) = $bot_config_dir."/blootbot.servers"; + my ($file) = $bot_config_dir . '/infobot.servers'; @ircServers = (); - %ircPort = (); + %ircPort = (); - if (!open(FILE, $file)) { - &ERROR("Failed reading server list ($file): $!"); - exit 0; + if ( !open( FILE, $file ) ) { + &ERROR("Failed reading server list ($file): $!"); + exit 0; } while () { - chop; - next if /^\s*$/; - next if /^[\#\[ ]/; - - if (/^(\S+)(:(\d+))?$/) { - push(@ircServers,$1); - $ircPort{$1} = ($3 || 6667); - } else { - &status("loadIRCServers: invalid line => '$_'."); - } + chop; + next if /^\s*$/; + next if /^[\#\[ ]/; + + if (/^\s*(\S+?)(:(\d+))?\s*$/) { + push( @ircServers, $1 ); + $ircPort{$1} = ( $3 || 6667 ); + } + else { + &status("loadIRCServers: invalid line => '$_'."); + } } close FILE; $file =~ s/^.*\///; - &status("Loaded $file (". scalar(@ircServers) ." servers)"); + &status( "Loaded $file (" . scalar(@ircServers) . ' servers)' ); } 1; + +# vim:ts=4:sw=4:expandtab:tw=80