line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dyatel; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
25284
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
61
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Dyatel - Internal |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.01 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 AUTHOR |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
andrey@kostenko.name |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 LICENSE |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
perl |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
25
|
1
|
|
|
1
|
|
31
|
use 5.010; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
53
|
|
26
|
1
|
|
|
1
|
|
1016
|
use mro 'c3'; |
|
1
|
|
|
|
|
873
|
|
|
1
|
|
|
|
|
6
|
|
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
1243
|
use Data::Dumper; |
|
1
|
|
|
|
|
21525
|
|
|
1
|
|
|
|
|
101
|
|
29
|
1
|
|
|
1
|
|
1048
|
use Net::Twitter::Stream; |
|
1
|
|
|
|
|
238133
|
|
|
1
|
|
|
|
|
45
|
|
30
|
1
|
|
|
1
|
|
1381
|
use WWW::Mechanize; |
|
1
|
|
|
|
|
230455
|
|
|
1
|
|
|
|
|
54
|
|
31
|
1
|
|
|
1
|
|
969
|
use YAML qw(LoadFile); |
|
1
|
|
|
|
|
15483
|
|
|
1
|
|
|
|
|
366
|
|
32
|
1
|
|
|
1
|
|
16
|
use base 'Class::Accessor::Fast'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1359
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( qw(twitter vkontakte mech) ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 new |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
43
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
44
|
0
|
|
|
|
|
|
my @files = grep { -e $_ } map glob, qw(~/.dyatel /usr/local/etc/dyatelrc /etc/dyatelrc); |
|
0
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
die "No config found\n" unless @files; |
46
|
0
|
|
|
|
|
|
my $self = $class->next::method(LoadFile($files[0])); |
47
|
0
|
|
|
|
|
|
$self->mech( WWW::Mechanize->new ); |
48
|
0
|
|
|
|
|
|
$self->mech->cookie_jar({}); |
49
|
0
|
|
|
|
|
|
return $self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 auth |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub auth { |
57
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
58
|
0
|
|
|
|
|
|
my $mech = $self->{mech}; |
59
|
0
|
|
|
|
|
|
$mech->get('http://vkontakte.ru/'); |
60
|
0
|
|
|
|
|
|
sleep 1; |
61
|
0
|
|
|
|
|
|
$mech->submit_form( form_number => 1, fields => $self->vkontakte ); |
62
|
0
|
|
|
|
|
|
$mech->submit_form( form_number => 1 ); |
63
|
0
|
0
|
|
|
|
|
($mech->content =~ // ) or die "Not authorized!\n"; |
64
|
0
|
|
|
|
|
|
Net::Twitter::Stream::Follow->new ( @{$self->twitter}{qw(login password)}, |
65
|
|
|
|
|
|
|
'9310862', |
66
|
0
|
|
|
0
|
|
|
sub { $self->got_tweet_callback(@_) } ); |
|
0
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 run |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub run { |
74
|
0
|
|
|
0
|
1
|
|
Danga::Socket->EventLoop; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 got_tweet_callback |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub got_tweet_callback { |
82
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
83
|
0
|
|
|
|
|
|
my $tweet = shift; |
84
|
0
|
0
|
|
|
|
|
return if $tweet->{text} =~ /^\@/; |
85
|
0
|
|
|
|
|
|
$self->mech->get('http://vkontakte.ru/'); |
86
|
0
|
|
|
|
|
|
sleep 1; |
87
|
0
|
|
|
|
|
|
($self->{activity_hash}) = ($self->mech->content =~ // ); |
88
|
0
|
|
|
|
|
|
sleep 1; |
89
|
0
|
|
|
|
|
|
$self->mech->post( 'http://vkontakte.ru/profile.php', { activityhash => $self->{activity_hash}, setactivity => $tweet->{text} } ); |
90
|
0
|
|
|
|
|
|
sleep 1; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; # End of Dyatel |