From: dms Date: Fri, 11 Aug 2000 12:10:19 +0000 (+0000) Subject: closed 17379 -- W3Search.pl gives duplicate output X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=5a152aa7f2b501dcae1b9dc376cc2f6edea43c8f;p=infobot.git closed 17379 -- W3Search.pl gives duplicate output git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@30 c11ca15a-4712-0410-83d8-924469b57eb5 --- diff --git a/src/Modules/W3Search.pl b/src/Modules/W3Search.pl index 72d78d3..470bb8d 100644 --- a/src/Modules/W3Search.pl +++ b/src/Modules/W3Search.pl @@ -32,21 +32,26 @@ sub W3Search { $Search->http_proxy($main::param{'httpProxy'}) if (&main::IsParam("httpProxy")); my $max = $Search->maximum_to_retrieve(10); # DOES NOT WORK. - my ($Result, $count); - my $r; - ### TODO: don't duplicate hosts. minimize like with the files - ### function. + my (%results, $count, $r); while ($r = $Search->next_result()) { - if ($Result) { - $Result .= " or ".$r->url(); + my $url = $r->url(); + + ### TODO: fix regex. + ### TODO: use array to preserve order. + if ($url =~ /^http:\/\/([\w\.]*)/) { + my $hostname = $1; + next if (exists $results{$hostname}); + $results{$hostname} = $url; } else { - $Result = $r->url(); + &main::DEBUG("W3S: url isn't good? ($url)."); } + last if ++$count >= $maxshow; } - if ($Result) { - $retval = "$where says \002$what\002 is at $Result"; + if (scalar keys %results) { + $retval = "$where says \002$what\002 is at ". + join(' or ', map { $results{$_} } sort keys %results); } &main::performStrictReply($retval);