rework answer

This commit is contained in:
Pavol Rusnak 2011-06-22 18:11:20 +02:00
parent fdac0b1044
commit db22869e4e

View file

@ -546,7 +546,6 @@ sub irc_public {
} }
if ( my ($alpha) = $what =~ /^!alpha (.+)/ ) { if ( my ($alpha) = $what =~ /^!alpha (.+)/ ) {
my $answer = '';
my $wa = WWW::WolframAlpha->new ( appid => 'P6XPHG-URK5HXVWXL', ); my $wa = WWW::WolframAlpha->new ( appid => 'P6XPHG-URK5HXVWXL', );
my $query = $wa->query( input => $alpha, ); my $query = $wa->query( input => $alpha, );
if ($query->success) { if ($query->success) {
@ -554,15 +553,16 @@ sub irc_public {
if (!$pod->error) { if (!$pod->error) {
foreach my $subpod (@{$pod->subpods}) { foreach my $subpod (@{$pod->subpods}) {
if ($subpod->plaintext) { if ($subpod->plaintext) {
my $answer = '';
$answer .= ($pod->title . ': ') if $pod->title; $answer .= ($pod->title . ': ') if $pod->title;
$answer .= ($subpod->title . ': ') if $subpod->title; $answer .= ($subpod->title . ': ') if $subpod->title;
$answer .= ($subpod->plaintext . "\n"); $answer .= $subpod->plaintext;
$irc->yield( privmsg => $channel => $answer );
} }
} }
} }
} }
} }
$irc->yield( privmsg => $channel => $answer ) if $answer;
} }
} }