3 # Search Zaurus Feeds Index (ZFI)
7 # Based on ZSI package by Darien Kruss <darien@kruss.com>
8 # Modified by Jordan Wiens <jordan@d0pe.com> (numatrix on #zaurus) and
9 # Eric Lin <anselor@d0pe.com> (anselor on #zaurus) to search ZFI instead of ZSI
11 # This script relies on the following page returning results
12 # http://zaurii.com/zfi/zfibot.php
13 # Returns the 5 latest/newest entries
15 # http://zaurii.com/zfi/zfibot.php?query=XXXX
16 # Returns all matches where XXX is in the name, description, etc
18 # Returned matches are pipe-separated, one record per line
19 # name|URL|description
21 # These are the phrases we get called for:
23 # 'zfi' or 'zfi <search>'
25 # We reply publicly or privately, depending how we were called
33 eval "use LWP::UserAgent";
41 &::status("zfi module requires LWP::UserAgent.");
47 my $ua = new LWP::UserAgent;
48 $ua->proxy('http', $::param{'httpProxy'}) if (&::IsParam("httpProxy"));
54 $searchpath = "http://zaurii.com/zfi/zfibot.php?query=$query";
56 $searchpath = "http://zaurii.com/zfi/zfibot.php";
59 my $request = new HTTP::Request('GET', "$searchpath");
60 my $response = $ua->request($request);
62 if (!$response->is_success) {
63 return "Something failed in connecting to the ZFI web server. Try again later.";
66 my $content = $response->content;
68 if ($content =~ /No entries found/im) {
69 return "No results were found searching ZFI for '$query'.";
72 my $res_count = 0; #local counter
73 my $res_display = 0; #results displayed
75 my @lines = split(/\n/,$content);
78 foreach my $line (@lines) {
79 if (length($line) > 10) {
80 my ($name, $href, $desc) = split(/\|/,$line);
82 if ($res_count < $res_return) {
83 $result .= "$name ($desc) $href : ";
90 if (($query) && ($res_count > $res_display)) {
91 $result .= "$res_display of $res_count shown. All at http://zaurii.com/zfi/index.phtml?p=r&r=$query";
99 &::performStrictReply(&queryText($args));
104 # vim: shiftwidth=2 tabstop=2