зеркало из https://github.com/mozilla/gecko-dev.git
Get mozillazine info from RDF; added ^DJI stock.
This commit is contained in:
Родитель
3d2af3ce85
Коммит
ecd4cba147
|
@ -55,7 +55,7 @@ use Chatbot::Eliza;
|
||||||
|
|
||||||
$|++;
|
$|++;
|
||||||
|
|
||||||
my $VERSION = "1.32"; # keep me in sync with the mozilla.org cvs repository
|
my $VERSION = "1.33"; # keep me in sync with the mozilla.org cvs repository
|
||||||
my $debug = 1; # debug output also includes warnings, errors
|
my $debug = 1; # debug output also includes warnings, errors
|
||||||
|
|
||||||
my %msgcmds = (
|
my %msgcmds = (
|
||||||
|
@ -68,7 +68,6 @@ my %pubcmds = (
|
||||||
"moon" => \&bot_moon,
|
"moon" => \&bot_moon,
|
||||||
"up" => \&bot_up,
|
"up" => \&bot_up,
|
||||||
"trees" => \&bot_tinderbox,
|
"trees" => \&bot_tinderbox,
|
||||||
"(mozillazine|zine|mz)" => \&bot_mozillazine,
|
|
||||||
"debug" => \&bot_debug,
|
"debug" => \&bot_debug,
|
||||||
"stocks" => \&bot_stocks,
|
"stocks" => \&bot_stocks,
|
||||||
);
|
);
|
||||||
|
@ -87,6 +86,7 @@ my %rdfcmds = (
|
||||||
"(newsbot|nb)" => "http://www.mozilla.org/newsbot/newsbot.rdf",
|
"(newsbot|nb)" => "http://www.mozilla.org/newsbot/newsbot.rdf",
|
||||||
"(xptoolkit|xpfe)" => "http://www.mozilla.org/xpfe/toolkit.rdf",
|
"(xptoolkit|xpfe)" => "http://www.mozilla.org/xpfe/toolkit.rdf",
|
||||||
"(freshmeat|fm)" => "http://freshmeat.net/files/freshmeat/fm.rdf",
|
"(freshmeat|fm)" => "http://freshmeat.net/files/freshmeat/fm.rdf",
|
||||||
|
"(mozillazine|zine|mz)" => "http://www.mozillazine.org/contents.rdf",
|
||||||
);
|
);
|
||||||
|
|
||||||
my %rdf_title;
|
my %rdf_title;
|
||||||
|
@ -153,14 +153,6 @@ my @greetings =
|
||||||
"ciao"
|
"ciao"
|
||||||
);
|
);
|
||||||
|
|
||||||
# leave $mozillazine undef'd if you don't want mozillazine
|
|
||||||
# headlines checked every eight hours
|
|
||||||
|
|
||||||
my $mozillazine = "http://www.mozillazine.org/index.html";
|
|
||||||
my @mozillazine;
|
|
||||||
my $last_mozillazine = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
my $irc = new Net::IRC or confess "$0: duh?";
|
my $irc = new Net::IRC or confess "$0: duh?";
|
||||||
|
|
||||||
|
@ -188,7 +180,6 @@ $bot->add_handler ('join', \&on_join);
|
||||||
&debug ("scheduling stuff");
|
&debug ("scheduling stuff");
|
||||||
$bot->schedule (0, \&tinderbox);
|
$bot->schedule (0, \&tinderbox);
|
||||||
$bot->schedule (0, \&checksourcechange);
|
$bot->schedule (0, \&checksourcechange);
|
||||||
$bot->schedule (0, \&mozillazine);
|
|
||||||
$bot->schedule (0, \&stocks);
|
$bot->schedule (0, \&stocks);
|
||||||
|
|
||||||
foreach my $i (keys %rdfcmds) {
|
foreach my $i (keys %rdfcmds) {
|
||||||
|
@ -452,7 +443,6 @@ sub bot_debug
|
||||||
my @list;
|
my @list;
|
||||||
my %last =
|
my %last =
|
||||||
(
|
(
|
||||||
"mozillazine" => $last_mozillazine,
|
|
||||||
"tinderbox" => $last_tree,
|
"tinderbox" => $last_tree,
|
||||||
"moon" => $last_moon,
|
"moon" => $last_moon,
|
||||||
);
|
);
|
||||||
|
@ -490,13 +480,6 @@ sub bot_rdfchannel {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub bot_mozillazine{
|
|
||||||
my ($nick, $cmd, $rest) = (@_);
|
|
||||||
do_headlines($nick,
|
|
||||||
"Headlines from mozillaZine (http://www.mozillazine.org/)",
|
|
||||||
\@mozillazine);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sub bot_hi {
|
sub bot_hi {
|
||||||
my ($nick, $cmd, $rest) = (@_);
|
my ($nick, $cmd, $rest) = (@_);
|
||||||
|
@ -812,41 +795,6 @@ sub create_pid_file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# fetches headlines from mozillaZine
|
|
||||||
#
|
|
||||||
# this should be a more general feature, to grab
|
|
||||||
# content.
|
|
||||||
|
|
||||||
|
|
||||||
sub mozillazine
|
|
||||||
{
|
|
||||||
return if (! defined $mozillazine);
|
|
||||||
&debug ("fetching mozillazine headlines");
|
|
||||||
|
|
||||||
my $output = get $mozillazine;
|
|
||||||
return if (! $output);
|
|
||||||
$last_mozillazine = time;
|
|
||||||
my @mz = split /\n/, $output;
|
|
||||||
|
|
||||||
@mozillazine = ();
|
|
||||||
|
|
||||||
foreach (@mz)
|
|
||||||
{
|
|
||||||
if (m@<!--head-->([^<>]+)<!--head-end-->@)
|
|
||||||
{
|
|
||||||
my $h = $1;
|
|
||||||
$h =~ s/ //g;
|
|
||||||
push @mozillazine, $h;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$bot->schedule (60 * 60 + 60, \&mozillazine);
|
|
||||||
push @mozillazine, "last updated: " . &logdate ($last_mozillazine);
|
|
||||||
reportDiffs("mozillaZine", "http://www.mozillazine.org/", \@mozillazine);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sub rdfchannel {
|
sub rdfchannel {
|
||||||
my ($foo, $url) = (@_);
|
my ($foo, $url) = (@_);
|
||||||
debug("fetching rdfchannel $url");
|
debug("fetching rdfchannel $url");
|
||||||
|
@ -967,7 +915,7 @@ sub stocks {
|
||||||
|
|
||||||
my $url = "http://quote.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgv&e=.csv&s=" .
|
my $url = "http://quote.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgv&e=.csv&s=" .
|
||||||
join("+", sort(keys %stocklist));
|
join("+", sort(keys %stocklist));
|
||||||
&debug ("fetching stock quotes");
|
&debug ("fetching stock quotes $url");
|
||||||
my $output = get $url;
|
my $output = get $url;
|
||||||
return if (!$output);
|
return if (!$output);
|
||||||
%stockvals = ();
|
%stockvals = ();
|
||||||
|
@ -975,7 +923,7 @@ sub stocks {
|
||||||
my @list = split(/,/, $line);
|
my @list = split(/,/, $line);
|
||||||
my $name = shift(@list);
|
my $name = shift(@list);
|
||||||
$name =~ s/"(.*)"/$1/;
|
$name =~ s/"(.*)"/$1/;
|
||||||
&debug ("parsing stock quote $name ($list[0])");
|
&debug ("parsing stock quote $name ($list[0]) $line");
|
||||||
$stockvals{$name} = \@list;
|
$stockvals{$name} = \@list;
|
||||||
foreach my $ref (@{$stockhist{$name}}) {
|
foreach my $ref (@{$stockhist{$name}}) {
|
||||||
my $oldval = $ref->[0];
|
my $oldval = $ref->[0];
|
||||||
|
@ -1001,17 +949,18 @@ sub stocks {
|
||||||
|
|
||||||
|
|
||||||
sub LoadStockList {
|
sub LoadStockList {
|
||||||
%stocklist = ("AOL" => [$channel]);
|
%stocklist = ("AOL" => [$channel],
|
||||||
|
"^DJI" => [$channel]);
|
||||||
|
|
||||||
if (open(LIST, $stockf)) {
|
if (open(LIST, $stockf)) {
|
||||||
%stocklist = ();
|
%stocklist = ();
|
||||||
while (<LIST>) {
|
while (<LIST>) {
|
||||||
my @list = split(/\|/, $_);
|
my @list = split(/\|/, $_);
|
||||||
my $name = shift(@list);
|
my $name = shift(@list);
|
||||||
$stocklist{$name} = \@list;
|
$stocklist{$name} = \@list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub FracStr {
|
sub FracStr {
|
||||||
|
@ -1021,8 +970,10 @@ sub FracStr {
|
||||||
$sign = "-";
|
$sign = "-";
|
||||||
$num = - $num;
|
$num = - $num;
|
||||||
} else {
|
} else {
|
||||||
$sign = $needplus ? "+" : "";
|
$sign = $needplus ? "+" : "";
|
||||||
}
|
$num =~ s/^\+//;
|
||||||
|
}
|
||||||
|
my $orignum = $num;
|
||||||
|
|
||||||
my $bdot = int($num);
|
my $bdot = int($num);
|
||||||
my $adot = $num - $bdot;
|
my $adot = $num - $bdot;
|
||||||
|
@ -1047,6 +998,7 @@ sub FracStr {
|
||||||
}
|
}
|
||||||
return "$sign$bdot$num/$base";
|
return "$sign$bdot$num/$base";
|
||||||
}
|
}
|
||||||
|
return "$sign$orignum";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче