Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use Config::Pit;
- use AnyEvent::Twitter;
- use AnyEvent::Twitter::Stream;
- use Mac::Growl ':all';
- use Encode;
- # Setting
- my $config = pit_get("twitter.com");
- my $done = AnyEvent->condvar;
- my $app_img = "/Users/acotie/Pictures/flyer.jpg";
- # Mac::Growl
- RegisterNotifications("Tracking-TwitStream", [qw/nomal warn/],[qw/normal/]);
- my $twitty = AnyEvent::Twitter->new(
- username => $config->{username},
- password => $config->{password},
- );
- # Tracking-Twitter-Streaming
- my $streamer = AnyEvent::Twitter::Stream->new(
- username => $config->{username},
- password => $config->{password},
- method => "track",
- ( track => 'perl,Perl,cpan,CPAN,#' ),
- on_tweet => sub {
- my $tweet = shift;
- my $screen_name = Encode::encode('utf8',$tweet->{user}{screen_name});
- my $text = Encode::encode('utf8',$tweet->{text});
- PostNotification("Tracking-TwitStream", "nomal", $screen_name, $text, "", "", $app_img);
- print "$screen_name: $text\n";
- },
- on_error => sub {
- my $error = shift;
- warn "ERROR: $error";
- $done->send;
- },
- on_eof => sub {
- $done->send;
- },
- );
- $done->recv;
Add Comment
Please, Sign In to add comment