From fdc42e4123ed1edcbbf56f7f40af2c7e8d8885c2 Mon Sep 17 00:00:00 2001 From: dms Date: Fri, 8 Nov 2002 17:11:51 +0000 Subject: [PATCH] - added http support to Debian - no more corruption! - news: fixed again! this time for good. disabled throttling. git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@614 c11ca15a-4712-0410-83d8-924469b57eb5 --- src/Modules/Debian.pl | 64 ++++++++++++++++++++----------------------- src/Modules/News.pl | 14 ++++++---- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/Modules/Debian.pl b/src/Modules/Debian.pl index f43804b..7043d65 100644 --- a/src/Modules/Debian.pl +++ b/src/Modules/Debian.pl @@ -17,6 +17,7 @@ my $refresh = &::getChanConfDefault("debianRefreshInterval",7) my $debug = 0; my $debian_dir = "$::bot_state_dir/debian"; my $country = "ca"; +my $protocol = "http"; my %dists = ( "unstable" => "sid", @@ -28,32 +29,32 @@ my %dists = ( my %urlcontents = ( "Contents-##DIST-i386.gz" => - "ftp://ftp.$country.debian.org". + "$protocol://ftp.$country.debian.org". "/debian/dists/##DIST/Contents-i386.gz", "Contents-##DIST-i386-non-US.gz" => - "ftp://non-us.debian.org". + "$protocol://non-us.debian.org". "/debian-non-US/dists/##DIST/non-US/Contents-i386.gz", ); my %urlpackages = ( "Packages-##DIST-main-i386.gz" => - "ftp://ftp.$country.debian.org". + "$protocol://ftp.$country.debian.org". "/debian/dists/##DIST/main/binary-i386/Packages.gz", "Packages-##DIST-contrib-i386.gz" => - "ftp://ftp.$country.debian.org". + "$protocol://ftp.$country.debian.org". "/debian/dists/##DIST/contrib/binary-i386/Packages.gz", "Packages-##DIST-non-free-i386.gz" => - "ftp://ftp.$country.debian.org". + "$protocol://ftp.$country.debian.org". "/debian/dists/##DIST/non-free/binary-i386/Packages.gz", "Packages-##DIST-non-US-main-i386.gz" => - "ftp://non-us.debian.org". + "$protocol://non-us.debian.org". "/debian-non-US/dists/##DIST/non-US/main/binary-i386/Packages.gz", "Packages-##DIST-non-US-contrib-i386.gz" => - "ftp://non-us.debian.org". + "$protocol://non-us.debian.org". "/debian-non-US/dists/##DIST/non-US/contrib/binary-i386/Packages.gz", "Packages-##DIST-non-US-non-free-i386.gz" => - "ftp://non-us.debian.org". + "$protocol://non-us.debian.org". "/debian-non-US/dists/##DIST/non-US/non-free/binary-i386/Packages.gz", ); @@ -107,46 +108,41 @@ sub DebianDownload { if ($url =~ /^ftp:\/\/(.*?)\/(\S+)\/(\S+)$/) { my ($host,$path,$thisfile) = ($1,$2,$3); -### HACK 1 -# if ($file =~ /Contents-woody-i386-non-US/) { -# &::DEBUG("Skipping Contents-woody-i386-non-US."); -# $file =~ s/woody/potato/; -# $path =~ s/woody/potato/; -# next; -# } - if (!&::ftpGet($host,$path,$thisfile,$file)) { &::WARN("deb: down: $file == BAD."); $bad++; next; } - if (! -f $file) { - &::WARN("deb: down: ftpGet: !file"); - $bad++; - next; - } - -### HACK2 -# if ($file =~ /Contents-potato-i386-non-US/) { -# &::DEBUG("hack: using potato's non-US contents for woody."); -# system("cp debian/Contents-potato-i386-non-US.gz debian/Contents-woody-i386-non-US.gz"); -# } + } elsif ($url =~ /^http:\/\/\S+\/\S+$/) { - my $exit = CORE::system("/bin/gzip -t $file >/dev/null 2>&1"); - if ($exit) { - &::WARN("deb: $file is corrupted :/"); - unlink $file; + if (!&::getURLAsFile($url,$file)) { + &::WARN("deb: down: http: $file == BAD."); + $bad++; next; } - - &::DEBUG("deb: download: good.") if ($debug); - $good++; + } else { &::ERROR("Debian: invalid format of url => ($url)."); $bad++; next; } + + if (! -f $file) { + &::WARN("deb: down: http: !file"); + $bad++; + next; + } + + my $exit = CORE::system("/bin/gzip -t $file >/dev/null 2>&1"); + if ($exit) { + &::WARN("deb: $file is corrupted :/"); + unlink $file; + next; + } + + &::DEBUG("deb: download: good.") if ($debug); + $good++; } # ok... lets just run this. diff --git a/src/Modules/News.pl b/src/Modules/News.pl index 0e5e843..419dfb8 100644 --- a/src/Modules/News.pl +++ b/src/Modules/News.pl @@ -786,7 +786,11 @@ sub latest { # scalar @new, !$flag my $unread = scalar @new; my $total = scalar keys %{ $::news{$chan} }; - if (!$flag && &::IsChanConf("newsTellUnread")) { + if (!$flag && !&::IsChanConf("newsTellUnread")) { + return; + } + + if (!$flag) { return unless ($unread); # just a temporary measure not to flood ourself off the @@ -826,11 +830,11 @@ sub latest { my $news = $sorted[$i]; next unless (defined $news); - my $age = time() - $::news{$chan}{$news}{Time}; +# my $age = time() - $::news{$chan}{$news}{Time}; + my $msg = sprintf("\002[\002%2d\002]\002 %s", $i, $news); +### $i, $_, &::Time2String($age) $::conn->schedule(int((2+$i)/2), sub { - &::notice($who, sprintf("\002[\002%2d\002]\002 %s", - $i, $news) ); -# $i, $_, &::Time2String($age) ) ); + &::notice($who, $msg); } ); } -- 2.39.5