| 1 | package Bot::BasicBot::Pluggable::Module::Stockquote; | ||||||||||||
| 2 | |||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 1 | ▶ | use Bot::BasicBot::Pluggable::Module; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 1 | ▶ | use base qw(Bot::BasicBot::Pluggable::Module); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 1 | ▶ | use Finance::Quote; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | 0 | ▶ | sub said { | ||||||||||
|
Subroutine
said: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||
| 10 | 0 | my ($self, $mess, $pri) = @_; | |||||||||||
| 11 | |||||||||||||
| 12 | 0 | my $body = $mess->{body}; | |||||||||||
| 13 | 0 | my $who = $mess->{who}; | |||||||||||
| 14 | |||||||||||||
| 15 | 0 | ▶ | return unless ($pri == 2); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 16 | |||||||||||||
| 17 | 0 | ▶ | return unless $body =~ m!quote\s+([A-Z]{3,4})(\s+|$)!i; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 18 | 0 | my $symbol = uc($1); | |||||||||||
| 19 | |||||||||||||
| 20 | |||||||||||||
| 21 | 0 | ▶ | my $q = Finance::Quote->new || return "Finance quoting seems to be broken"; | ||||||||||
|
Condition0%0/2
'Finance::Quote'->new || (return 'Finance quoting seems to be broken')
MC/DC0%0/1
'Finance::Quote'->new || (return 'Finance quoting seems to be broken')
'Finance::Quote'->new
Truth table0%0/2
A
A= 'Finance::Quote'->new
| |||||||||||||
| 22 | |||||||||||||
| 23 | 0 | my @sources = $q->sources; | |||||||||||
| 24 | |||||||||||||
| 25 | |||||||||||||
| 26 | |||||||||||||
| 27 | 0 | foreach my $source (@sources) { | |||||||||||
| 28 | 0 | my %hash = $q->fetch($source, $symbol); | |||||||||||
| 29 | 0 | ▶ | next unless defined $hash{$symbol,'price'}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 30 | return sprintf "At %s %s %s traded at %s", $hash{$symbol,'date'}, | ||||||||||||
| 31 | $hash{$symbol,'time'}, | ||||||||||||
| 32 | $symbol, | ||||||||||||
| 33 | 0 | $hash{$symbol,'last'}; | |||||||||||
| 34 | } | ||||||||||||
| 35 | |||||||||||||
| 36 | 0 | return "Couldn't get a value for $symbol"; | |||||||||||
| 37 | } | ||||||||||||
| 38 | |||||||||||||
| 39 | 0 | ▶ | sub help { | ||||||||||
|
Subroutine
help: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 40 | 0 | return "Commands: 'yow' or 'be zippy'"; | |||||||||||
| 41 | } | ||||||||||||
| 42 | |||||||||||||
| 43 | 1 | 1; | |||||||||||
| 44 | |||||||||||||
| 45 | =head1 NAME | ||||||||||||
| 46 | |||||||||||||
| 47 | Bot::BasicBot::Pluggable::Module::Stockquote - Get stock quote | ||||||||||||
| 48 | |||||||||||||
| 49 | |||||||||||||
| 50 | =head1 SYNOPSIS | ||||||||||||
| 51 | |||||||||||||
| 52 | This allows you to get a stock quote for a symbol from various stock services | ||||||||||||
| 53 | |||||||||||||
| 54 | =head1 IRC USAGE | ||||||||||||
| 55 | |||||||||||||
| 56 | quote <LETTER-TICKERNAME> | ||||||||||||
| 57 | |||||||||||||
| 58 | =head1 AUTHOR | ||||||||||||
| 59 | |||||||||||||
| 60 | Simon Wistow, <simon@thegestalt.org> | ||||||||||||
| 61 | |||||||||||||
| 62 | =head1 COPYRIGHT | ||||||||||||
| 63 | |||||||||||||
| 64 | Copyright 2005, Simon Wistow | ||||||||||||
| 65 | |||||||||||||
| 66 | Distributed under the same terms as Perl itself. | ||||||||||||
| 67 | |||||||||||||
| 68 | =head1 SEE ALSO | ||||||||||||
| 69 | |||||||||||||
| 70 | |||||||||||||
| 71 | =cut | ||||||||||||
| 72 | |||||||||||||