]> git.donarmstrong.com Git - infobot.git/commitdiff
zfi/zsi searching for #zaurus
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Sat, 2 Nov 2002 05:34:04 +0000 (05:34 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Sat, 2 Nov 2002 05:34:04 +0000 (05:34 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@588 c11ca15a-4712-0410-83d8-924469b57eb5

files/sample/sample.chan
src/CommandStubs.pl
src/Modules/zfi.pl [new file with mode: 0644]
src/Modules/zsi.pl [new file with mode: 0644]
src/modules.pl

index 94dfbd2c14af485295a0fbfb1fd4a462ab27b1d0..efc27adad8106995bbc67640d6155cfa46dced88 100644 (file)
@@ -58,4 +58,6 @@ _default
     +units
     +userinfo
     +wwwsearch
+    +zfi
+    +zsi
 
index 93f1cea627faacfccedcf007dfed1025f37dd548..9c68e2cf5d8005ba08bcdacf26c9e6184e24e010 100644 (file)
@@ -224,6 +224,12 @@ sub parseCmdHook {
 &addCmdHook("extra", 'bzfquery', ('CODEREF' => 'BZFlag::query',
        'Identifier' => 'bzflag', 'Cmdstats' => 'BZFlag',
        'Forker' => 1, 'Help' => 'bzflag') );
+&addCmdHook("extra", 'zfi', ('CODEREF' => 'zfi::query',
+       'Identifier' => 'zfi', 'Cmdstats' => 'zfi',
+       'Forker' => 1) );
+&addCmdHook("extra", 'zsi', ('CODEREF' => 'zsi::query',
+       'Identifier' => 'zsi', 'Cmdstats' => 'zsi',
+       'Forker' => 1) );
 
 ###
 ### END OF ADDING HOOKS.
diff --git a/src/Modules/zfi.pl b/src/Modules/zfi.pl
new file mode 100644 (file)
index 0000000..4584119
--- /dev/null
@@ -0,0 +1,103 @@
+package zfi;
+
+# Search Zaurus Feeds Index (ZFI)
+# Version 1.0
+# Released 02 Oct 2002
+
+# Based on ZSI package by Darien Kruss <darien@kruss.com>
+# Modified by Jordan Wiens <jordan@d0pe.com> (numatrix on #zaurus) and
+# Eric Lin <anselor@d0pe.com> (anselor on #zaurus) to search ZFI instead of ZSI
+
+# This script relies on the following page returning results
+# http://zaurii.com/zfi/zfibot.php
+# Returns the 5 latest/newest entries
+
+# http://zaurii.com/zfi/zfibot.php?query=XXXX
+# Returns all matches where XXX is in the name, description, etc
+
+# Returned matches are pipe-separated, one record per line
+# name|URL|description
+
+# These are the phrases we get called for:
+
+# 'zfi'  or  'zfi <search>'
+
+# We reply publicly or privately, depending how we were called
+
+my $no_zfi;
+
+BEGIN {
+       $no_zfi = 0;
+       eval "use LWP::UserAgent";
+       $no_zfi++ if ($@);
+}
+
+sub queryText {
+       my ($query) = @_;
+
+       if ($no_zfi) {
+               &main::status("zfi module requires LWP::UserAgent.");
+               return '';
+       }
+
+       my $res_return = 5;
+
+       my $ua = new LWP::UserAgent;
+  $ua->proxy('http', $::param{'httpProxy'}) if (&::IsParam("httpProxy"));
+
+       $ua->timeout(10);
+
+       my $searchpath;
+       if ($query) {
+               $searchpath = "http://zaurii.com/zfi/zfibot.php?query=$query";
+       } else {
+               $searchpath = "http://zaurii.com/zfi/zfibot.php";
+       }
+
+       my $request = new HTTP::Request('GET', "$searchpath");
+       my $response = $ua->request($request); 
+
+       if (!$response->is_success) {
+               return "Something failed in connecting to the ZFI web server. Try again later.";
+       }
+
+       my $content = $response->content;
+
+       if ($content =~ /No entries found/im) {
+               return "$result No results were found searching ZFI for '$query'.";
+       }
+
+       my $res_count = 0; #local counter
+       my $res_display = 0; #results displayed
+
+       my @lines = split(/\n/,$content);
+
+       my $result = '';
+       foreach $line(@lines) {
+               if (length($line) > 10) {
+                       my ($name, $href, $desc) = split(/\|/,$line);
+
+                       if ($res_count < $res_return) {
+                               $result .= "$name ($desc) $href\n";
+                               $res_display ++;
+                       }
+                       $res_count ++;
+               }
+       }
+
+       if (($query) && ($res_count > $res_display)) {
+               $result .= "$res_display of $res_count shown. All at http://zaurii.com/zfi/index.phtml?p=r&r=$query\n";
+       }
+
+       return $result;
+}
+
+sub query {
+       my ($args) = @_;
+       &::performStrictReply(&queryText($args));
+  return;
+}
+
+1;
+# vim: shiftwidth=2 tabstop=2
+__END__
diff --git a/src/Modules/zsi.pl b/src/Modules/zsi.pl
new file mode 100644 (file)
index 0000000..51600a5
--- /dev/null
@@ -0,0 +1,103 @@
+package zsi;
+
+# Search Zaurus Software Index (ZSI)
+# Version 1.0
+# Released 26 Aug 2002
+
+# Developed by Darien Kruss <darien@kruss.com>
+# http://zaurus.kruss.com/
+# usually hangs out on #zaurus as 'darienm'
+
+# This script relies on the following page returning results
+# http://killefiz.de/zaurus/zsibot.php
+# Returns the 5 latest/newest entries
+
+# http://killefiz.de/zaurus/zsibot.php?query=XXXX
+# Returns all matches where XXX is in the name, description, etc
+
+# Returned matches are pipe-separated, one record per line
+# name|URL|description
+
+# These are the phrases we get called for:
+
+# 'zsi'  or  'zsi <search>'
+
+# We reply publicly or privately, depending how we were called
+
+my $no_zsi;
+
+BEGIN {
+       $no_zsi = 0;
+       eval "use LWP::UserAgent";
+       $no_zsi++ if ($@);
+}
+
+sub queryText {
+       my ($query) = @_;
+
+       if ($no_zsi) {
+               &main::status("zsi module requires LWP::UserAgent.");
+               return '';
+       }
+
+       my $res_return = 5;
+
+       my $ua = new LWP::UserAgent;
+  $ua->proxy('http', $::param{'httpProxy'}) if (&::IsParam("httpProxy"));
+
+       $ua->timeout(10);
+
+       my $searchpath;
+       if ($query) {
+               $searchpath = "http://killefiz.de/zaurus/zsibot.php?query=$query";
+       } else {
+               $searchpath = "http://killefiz.de/zaurus/zsibot.php";
+       }
+
+       my $request = new HTTP::Request('GET', "$searchpath");
+       my $response = $ua->request($request); 
+
+       if (!$response->is_success) {
+               return "Something failed in connecting to the ZSI web server. Try again later.";
+       }
+
+       my $content = $response->content;
+
+       if ($content =~ /No entries found/im) {
+               return "$result No results were found searching ZSI for '$query'.";
+       }
+
+       my $res_count = 0; #local counter
+       my $res_display = 0; #results displayed
+
+       my @lines = split(/\n/,$content);
+
+       my $result = '';
+       foreach $line(@lines) {
+               if (length($line) > 10) {
+                       my ($name, $href, $desc) = split(/\|/,$line);
+
+                       if ($res_count < $res_return) {
+                               $result .= "$name ($desc) $href\n";
+                               $res_display ++;
+                       }
+                       $res_count ++;
+               }
+       }
+
+       if (($query) && ($res_count > $res_display)) {
+               $result .= "$res_display of $res_count shown. All at http://killefiz.de/zaurus/search.php?q=$query\n";
+       }
+
+       return $result;
+}
+
+sub query {
+       my ($args) = @_;
+       &::performStrictReply(&queryText($args));
+  return;
+}
+
+1;
+# vim: shiftwidth=2 tabstop=2
+__END__
index 6ab39e91e63f6a91f99afd9f17ec37b45fc0a5d0..0cae3423342c6aae1ecdb2783eba3613b944e314 100644 (file)
@@ -45,6 +45,8 @@ if ($@) {
        "wwwsearch"     => "W3Search.pl",
        "whatis"        => "WhatIs.pl",
        "wingate"       => "Wingate.pl",
+       "zfi"           => "zfi.pl",
+       "zsi"           => "zsi.pl",
        "insult"        => "insult.pl",
        "nickometer"    => "nickometer.pl",
        "babelfish"     => "babel.pl",