Guest User

Untitled

a guest
Mar 12th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Config::Pit;
  5. use AnyEvent::Twitter;
  6. use AnyEvent::Twitter::Stream;
  7. use Mac::Growl ':all';
  8. use Encode;
  9.  
  10. # Setting
  11. my $config = pit_get("twitter.com");
  12. my $done = AnyEvent->condvar;
  13. my $app_img = "/Users/acotie/Pictures/flyer.jpg";
  14.  
  15. # Mac::Growl
  16. RegisterNotifications("Tracking-TwitStream", [qw/nomal warn/],[qw/normal/]);
  17.  
  18. my $twitty = AnyEvent::Twitter->new(
  19. username => $config->{username},
  20. password => $config->{password},
  21. );
  22.  
  23. # Tracking-Twitter-Streaming
  24. my $streamer = AnyEvent::Twitter::Stream->new(
  25. username => $config->{username},
  26. password => $config->{password},
  27. method => "track",
  28. ( track => 'perl,Perl,cpan,CPAN,#' ),
  29. on_tweet => sub {
  30. my $tweet = shift;
  31.  
  32. my $screen_name = Encode::encode('utf8',$tweet->{user}{screen_name});
  33. my $text = Encode::encode('utf8',$tweet->{text});
  34.  
  35. PostNotification("Tracking-TwitStream", "nomal", $screen_name, $text, "", "", $app_img);
  36. print "$screen_name: $text\n";
  37.  
  38. },
  39. on_error => sub {
  40. my $error = shift;
  41. warn "ERROR: $error";
  42. $done->send;
  43. },
  44. on_eof => sub {
  45. $done->send;
  46. },
  47. );
  48.  
  49. $done->recv;
Add Comment
Please, Sign In to add comment