3 # Search Zaurus Software Index (ZSI)
7 # Developed by Darien Kruss <darien@kruss.com>
8 # http://zaurus.kruss.com/
9 # usually hangs out on #zaurus as 'darienm'
11 # This script relies on the following page returning results
12 # http://killefiz.de/zaurus/zsibot.php
13 # Returns the 5 latest/newest entries
15 # http://killefiz.de/zaurus/zsibot.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 # 'zsi' or 'zsi <search>'
25 # We reply publicly or privately, depending how we were called
33 eval "use LWP::UserAgent";
41 &::status("zsi module requires LWP::UserAgent.");
47 my $ua = new LWP::UserAgent;
48 $ua->proxy( 'http', $::param{'httpProxy'} ) if ( &::IsParam('httpProxy') );
54 $searchpath = "http://killefiz.de/zaurus/zsibot.php?query=$query";
57 $searchpath = "http://killefiz.de/zaurus/zsibot.php";
60 my $request = new HTTP::Request( 'GET', "$searchpath" );
61 my $response = $ua->request($request);
63 if ( !$response->is_success ) {
65 "Something failed in connecting to the ZSI web server. Try again later.";
68 my $content = $response->content;
70 if ( $content =~ /No entries found/im ) {
71 return "No results were found searching ZSI for '$query'.";
74 my $res_count = 0; #local counter
75 my $res_display = 0; #results displayed
77 my @lines = split( /\n/, $content );
80 foreach my $line (@lines) {
81 if ( length($line) > 10 ) {
82 my ( $name, $href, $desc ) = split( /\|/, $line );
84 if ( $res_count < $res_return ) {
85 $result .= "$name ($desc) $href : ";
92 if ( ($query) && ( $res_count > $res_display ) ) {
94 "$res_display of $res_count shown. All at http://killefiz.de/zaurus/search.php?q=$query";
102 &::performStrictReply( &queryText($args) );
108 # vim:ts=4:sw=4:expandtab:tw=80