#!c:/perl/bin/perl -w $| = 1; use strict; use CGI; use LWP::Simple; use XML::Simple (); my $q = CGI->new(); print $q->header( { Cache_control => 'no-cache', Expires => '-1y', Content_type => 'text/xml' } ), qq{
}; my $xml = XML::Simple->new(); my $chatter = get( 'http://www.perlmonks.org/index.pl?node_id=207304' ); my $chat = $xml->XMLin( $chatter, ForceArray => [ 'message' ] ); my $last_id = $q->param('last_id') || 0; my $doc_count = $q->param('doc_count') || 0; ++$doc_count; unless ( $q->param('skipintro') ) { print qq{ Welcome to the purl-munks voice XML chatterbox listener. Whenever you hear the }; } if ( $doc_count == 19 ) { print qq{ User input required. Press one to continue listening. Thank you. \\!p1000 }; } else { print qq{ }; } if ( grep { $_->{message_id} > $last_id } @{ $chat->{message} } ) { print qq{ }; } else { print qq{ }; } for my $msg ( @{ $chat->{message} } ) { next if ( $msg->{message_id} <= $last_id ); my $txt = $msg->{text}; # Fix up output to sound better in oral speech. # This could use a _heck_ of a lot of work. # strip out links $txt =~ s!\[[^\|]+\|([^\]]+)\]!$1!g; $txt =~ s!\[([^\]]+)\]!$1!g; # remove html tags. 1 while $txt =~ s!<[^>]+>!!g; # remove smileys :) $txt =~ s![:;]\-?[\(\)\|]!!g; # remove [tye]-type smileys (: $txt =~ s![\(\)\|]\-?[:;]!!g; if ( $txt =~ s!\A/me!! ) { print qq{ $msg->{author} \\!p2000 }; } else { print qq{ $msg->{author} says: \\!p500 \\!p2000 }; } $last_id = $msg->{message_id}; } print qq{ \\!p35000
};