1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut synced 2025-06-08 00:15:42 -04:00

working with new api and url, fixed thanks to https://bugs.launchpad.net/ibid/+bug/700475

This commit is contained in:
Ryan Voots 2012-07-07 15:05:40 -04:00
parent 269090122d
commit 4b6445e4cb

View file

@ -13,14 +13,14 @@ sub {
warn 1; warn 1;
if( $q =~ /^\s*(?:(?:help|wtf|\?|\:)\s*)?$/i ) if( $q =~ /^\s*(?:(?:help|wtf|\?|\:)\s*)?$/i )
{ {
print "see http://tinyurl.com/7xmvs and http://tinyurl.com/2blo2w"; print "see http://oeis.org/";
return; return;
} }
warn 2; warn 2;
my $uri = "http://www.research.att.com/~njas/sequences/?q=" . CGI::escape($q) . "&n=1&fmt=3"; my $uri = "http://oeis.org/search?q=" . CGI::escape($q)."&fmt=text";
local $_ = get($uri); # change this in the real plugin local $_ = get($uri); # change this in the real plugin
warn 2.5; warn 2.5;
if (/^Results .* of (\d+) results/mi) { if (/^Showing .* of (\d+)/mi) {
my $nrfound = $1; my $nrfound = $1;
unless( /^%N (\S+) (.*)/m ) unless( /^%N (\S+) (.*)/m )
{ {
@ -34,20 +34,20 @@ sub {
$elts =~ s/,,+/,/g; $elts =~ s/,,+/,/g;
warn 3.5; warn 3.5;
if (1 == $nrfound) { if (1 == $nrfound) {
my $outuri = sprintf "http://tinyurl.com/4zq4q/%.10s", $anum; my $outuri = sprintf "http://oeis.org/%s", $anum;
print sprintf "%s %.256s: %.512s", $outuri, $title, $elts; print sprintf "%s %.256s: %.512s", $outuri, $title, $elts;
} else { } else {
my $outuri1 = "http://www.research.att.com/~njas/sequences/?q=" . CGI::escape($q); my $outuri1 = "http://oeis.org/searchs?q=" . CGI::escape($q);
warn 3.6; warn 3.6;
my $outuri = makeashorterlink($outuri1) || $outuri1; # my $outuri = makeashorterlink($outuri1) || $outuri1;
print sprintf "%s %.10s(1/%d) %.256s: %.512s", $outuri, $anum, $nrfound, $title, $elts; print sprintf "%s %.10s(1/%d) %.256s: %.512s", $outuri1, $anum, $nrfound, $title, $elts;
} }
} elsif (/^no matches/mi) { } elsif (/^no matches/mi) {
print "No matches found"; print "No matches found";
warn 4 warn 4
} else { } else {
warn 5; warn 5;
print "Reply from OEIS in unknown format"; print "Reply from OEIS in unknown format: $_";
} }
} }