[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Infobot Modules
- Date: Fri, 07 Jan 2000 07:54:16 -0500
- From: Kevin Lenzo <lenzo@cs.cmu.edu>
- Subject: Re: Infobot Modules
hi folks,
Teckle did Infobot::Module::Stock.pm as a module, to answer
the immediate question (simon i was to slow in converting
stock.pl to a module, and the new one is quite compact), but
that raises the issue of who does what to which modules.
the Infobot will be on CPAN, and I'm sure that I would be
overwhelmed and slow if I independently made every change to
the Infobot::Modules that other people develop; furthermore,
I hope people will put things under the Infobot::Module
directory on CPAN using PAUSE without me being involved.
I think I'll try to keep the Infobot core with a few modules,
and then have a Bundle on CPAN for pulling in all the
modules there. That means that module authors should probably
all get PAUSE ids, though it's not required, of course.
So far, the contributed Modules have been in the .tar.gz
files on
http://www.infobot.org/dev/
and the discussion is archived on
http://www.infobot.org/list/
which has most of the submissions, it it's awkward to get
to because the modules aren't individually available yet.
I'll make a burst directory that has the whole source
open, but this will just be a short-term solution for
having the whole tree under CVS.
Simon Cozens wrote:
>
> On Fri, Jan 07, 2000 at 05:16:13PM +0800, Jason Jordan wrote:
> > Has anyone written a module for Infobot that will grab stock quotes, the
> > Dow and NASDAQ?
>
> I've sent the quote.pl thingy separately. I've not be following the current
> thread very well - do we have a central repository for these extensions now?
>
> Simon
> --
> As in certain cults it is possible to kill a process if you know its true name.
> -- Ken Thompson and Dennis M. Ritchie
included below is Infobot::Module::Stock.pm in its current
state.
cheers,
kevin
#
# Stock -- infobot module for stock quote lookups.
# requires the LWP::Simple module.
# By Jay Jacobs (teckle)
# CSV pointers from Carl Boernecke (Rizz)
#
package Infobot::Module::Stock;
use strict;
use Infobot::Module;
$Infobot::Module::Stock::VERSION = "0.10_00";
$Infobot::Module{"Stock"} = $Infobot::Module::Stock::VERSION;
@Infobot::Module::Stock::ISA = qw(Infobot::Module);
my $any_bad;
BEGIN {
eval { require LWP::Simple };
$@ and $any_bad = "LWP::Simple";
warn "Infobot::Module::Stock requires $any_bad" if $any_bad;
}
sub Infobot::Module::Stock::new {
my $class = shift ;
return undef if $any_bad;
my $self = $class->SUPER::new(@_);
$self->weight(0);
$self->enabled(1);
$self->name('Stock');
$self->regex(qr/stock\s+(?:price |quote |for )?\s*(?:for|at|of)?\s*(\S+)/i);
$self->usage('stock <SYMBOL>');
$self->descrip("Tries to lookup stock quote for SYMBOL");
bless $self, $class;
}
sub Infobot::Module::Stock::action {
my ($self, $message) = @_;
return undef unless $self->enabled;
my $symbol = uc($message->get('args')->[0]);
$self->status(5,"looking up stock for $symbol");
my $content = LWP::Simple::get("http://finance.yahoo.com/d/quotes.csv?s=$symbo
l\&f=sl1d1t1c1ohgv\&e=.csv");
return("$symbol: could not get information") if (! defined $content);
my ($trade, $change) = (split(/,/, $content))[1,4];
return("stock symbol '$symbol' doesn't exist") if ($trade eq "0.00");
return("$symbol last traded at $trade ($change change)");
}
1;
__END__
=head1 NAME
Stock -- looks up the current stock quote of a given stock.
=head1 SYNOPSIS
stock for <SYMBOL>
stock quote for <SYMBOL>
=head1 PREREQUISITES
LWP::Simple
=head1 DESCRIPTION
Connects up to yahoo's stock webpage, pulls down
a CSV file and parses it for the info.
=head1 AUTHORS
Jay Jacobs (teckle) <jjacobs@securetty.org>
Rizz++ for the csv information.