daily pastebin goal
61%
SHARE
TWEET

Untitled

a guest Oct 11th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use strict;
  2. use warnings;
  3. use utf8;
  4.  
  5. use AnyEvent;
  6. use AnyEvent::Twitter;
  7. use AnyEvent::Twitter::Stream;
  8. use Config::Pit;
  9. use Growl::Any;
  10.  
  11. my $auth = Config::Pit::get('twitter.koetter');
  12. my $cv = AE::cv;
  13.  
  14. my @tweets;
  15. my $method = 'filter';
  16. my $name = 'Koetter_dev';
  17.  
  18. my $growl = Growl::Any->new;
  19. $growl->register('twitter.pl', ['Default']);
  20. $growl->notify('', 'twitter.pl', '起動...');
  21.  
  22. my $pop = AnyEvent->timer(
  23.     after    => 0,
  24.     interval => 6,
  25.     cb       => sub {
  26.         if(scalar @tweets >= 1) {
  27.             my $tweet = shift @tweets;
  28.             $growl->notify($tweet->{user}->{profile_image_url}, $tweet->{user}->{name}, $tweet->{text}, $tweet->{user}->{profile_image_url});
  29.         }
  30.     },
  31. );
  32.  
  33. my $stream = AnyEvent::Twitter::Stream->new(
  34.     %$auth,
  35.     method => $method,
  36.     track  => '@' . $name,
  37.     on_tweet => sub {
  38.         my $tweet = shift;
  39.         push @tweets, $tweet;
  40.     },
  41.     on_error => sub {
  42.         my $tweet = shift;
  43.         print "ERROR: $tweet\n";
  44.     },
  45. );
  46.  
  47. $cv->recv;
  48.  
  49. __END__
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top