]> git.donarmstrong.com Git - infobot.git/commitdiff
- added http support to Debian - no more corruption!
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Fri, 8 Nov 2002 17:11:51 +0000 (17:11 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Fri, 8 Nov 2002 17:11:51 +0000 (17:11 +0000)
- news: fixed again! this time for good. disabled throttling.

git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@614 c11ca15a-4712-0410-83d8-924469b57eb5

blootbot/src/Modules/Debian.pl
blootbot/src/Modules/News.pl

index f43804b8e366cf86cb10ca538d7ffdcd5d4f7ce0..7043d65b2db44452ad88dad2e2d1f2f7cd26b7a0 100644 (file)
@@ -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.
index 0e5e8432d10d06340af278d73eaa4c122eaf39d9..419dfb8f2330a1790cdcedc016cdb3ac555344b0 100644 (file)
@@ -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);
            } );
        }