1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#!/usr/bin/env perl
use utf8;
use v5.12;
use AnyEvent::Twitter::Stream;
use Encode;
use Furl;
use Config::Pit;
my $config = pit_get(
'nqounet@twitter.com',
require => {
consumer_key => 'consumer_key',
consumer_secret => 'consumer_secret',
token => 'access_token',
token_secret => 'access_token_secret',
}
);
my $furl = Furl->new;
my $done = AE::cv;
my $listener = AnyEvent::Twitter::Stream->new(
method => 'filter',
track => 'Perl入学式',
on_tweet => sub {
my $tweet = shift;
$furl->post(
'https://idobata.io/hook/generic/xxxxxxxxxxxxxxx',
['Content-Type' => 'application/x-www-form-urlencoded'],
[source => encode_utf8(qq{$tweet->{user}{name} : $tweet->{text}})]
);
},
%{$config}
);
$done->recv;
|