Guest User

Untitled

a guest
Apr 9th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #!/usr/bin/perl
  2. # TWITTER_USERNAME=xxx TWITTER_PASSWORD=xxx plackup -s Twiggy tweet_displayer.pl
  3. use strict;
  4. use AnyEvent::Twitter::Stream;
  5. use Encode;
  6. use Markapl;
  7.  
  8. my @buf;
  9.  
  10. my $stream = AnyEvent::Twitter::Stream->new(
  11. username => $ENV{TWITTER_USERNAME},
  12. password => $ENV{TWITTER_PASSWORD},
  13. method => 'sample',
  14. on_tweet => sub {
  15. my $tweet = shift;
  16. unshift @buf, $tweet;
  17. @buf = @buf[0..9] if @buf >= 10;
  18. },
  19. );
  20.  
  21. sub {
  22. $stream; # <- reference
  23. my $mp = html { body { ul { map { li { $_->{text} } } @buf } } };
  24. return [ 200, [ 'Content-Type', 'text/html' ], [ encode_utf8( $mp->() ) ] ];
  25. };
Add Comment
Please, Sign In to add comment