Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#! /usr/bin/env perl
use strict;
use warnings;
use AnyEvent::Twitter::Stream;
use Config::Pit;
use Growl::Any;
use Encode;
my $config = pit_get('example.com', require => {
consumer_key => 'your twitter consumer_key',
consumer_secret => 'your twitter consumer_secret',
token => 'your twitter access_token',
token_secret => 'your twitter access_token_secret',
});
my $growl = Growl::Any->new;
$growl->register("Growl/Twitter", ["tweet"]);
my $done = AE::cv;
my $streamer; $streamer = AnyEvent::Twitter::Stream->new(
consumer_key => $config->{consumer_key},
consumer_secret => $config->{consumer_secret},
token => $config->{token},
token_secret => $config->{token_secret},
method => 'userstream',
on_tweet => sub {
my $tweet = shift;
$growl->notify(
"tweet",
encode_utf8($tweet->{user}{screen_name}),
encode_utf8($tweet->{text}),
$tweet->{user}{profile_image_url},
);
},
on_error => sub {
my $error = shift;
warn "ERROR: $error";
$done->send;
},
on_eof => sub {
$done->send;
},
);
$done->recv;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment