line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Twirc::Plugin::SecondaryAccount; |
2
|
|
|
|
|
|
|
$App::Twirc::Plugin::SecondaryAccount::VERSION = '0.18'; # TRIAL |
3
|
1
|
|
|
1
|
|
811
|
use Moose; |
|
1
|
|
|
|
|
310931
|
|
|
1
|
|
|
|
|
7
|
|
4
|
1
|
|
|
1
|
|
4595
|
use Net::Twitter; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
704
|
use POE::Component::Server::Twirc; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has net_twitter_options => ( isa => 'HashRef', is => 'ro', default => sub { {} } ); |
8
|
|
|
|
|
|
|
has username => ( isa => 'Str', is => 'ro', required => 1 ); |
9
|
|
|
|
|
|
|
has password => ( isa => 'Str', is => 'ro', required => 1 ); |
10
|
|
|
|
|
|
|
has option => ( isa => 'Str', is => 'ro' ); |
11
|
|
|
|
|
|
|
has _twitter => ( isa => 'Net::Twitter', is => 'rw' ); |
12
|
|
|
|
|
|
|
has _option_regex => ( isa => 'Maybe[RegexpRef]', is => 'rw', default => undef ); |
13
|
|
|
|
|
|
|
has _useragent_class => ( isa => 'Str', is => 'ro', default => 'LWP::UserAgent::POE' ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub BUILD { |
16
|
|
|
|
|
|
|
my $self = shift; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$self->_twitter(Net::Twitter->new( |
19
|
|
|
|
|
|
|
username => $self->username, |
20
|
|
|
|
|
|
|
password => $self->password, |
21
|
|
|
|
|
|
|
source => 'twircgw', |
22
|
|
|
|
|
|
|
useragent => 'twirc/' . POE::Component::Server::Twirc->VERSION, |
23
|
|
|
|
|
|
|
useragent_class => $self->_useragent_class, |
24
|
|
|
|
|
|
|
%{$self->net_twitter_options}, |
25
|
|
|
|
|
|
|
)); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
if ( $self->option ) { |
28
|
|
|
|
|
|
|
my $option = quotemeta $self->option; |
29
|
|
|
|
|
|
|
$self->_option_regex(qr/^-$option(only)?\s+/); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub cmd_post { |
34
|
|
|
|
|
|
|
my ($self, $server, $channel, $nick, $textref) = @_; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $only; |
37
|
|
|
|
|
|
|
if ( my $option_regex = $self->_option_regex ) { |
38
|
|
|
|
|
|
|
$$textref =~ s/$option_regex// || return; |
39
|
|
|
|
|
|
|
$only = $1; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$self->_twitter->update($$textref); |
43
|
|
|
|
|
|
|
return $only; # return a true value to stop the processing chain |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
no Moose; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
App::Twirc::Plugin::SecondaryAccount - Cross post updates (DEPRECATED) |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# in config (.yml in this example) |
61
|
|
|
|
|
|
|
plugins: |
62
|
|
|
|
|
|
|
- SecondaryAccount |
63
|
|
|
|
|
|
|
username: my_other_screen_name |
64
|
|
|
|
|
|
|
password: my_other_twitter_password |
65
|
|
|
|
|
|
|
option: fb |
66
|
|
|
|
|
|
|
- SecondaryAccount |
67
|
|
|
|
|
|
|
username: yet_another_screen_name |
68
|
|
|
|
|
|
|
password: yet_another_password |
69
|
|
|
|
|
|
|
net_twitter_options: |
70
|
|
|
|
|
|
|
apiurl: http://identi.ca/api |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# In your IRC client... |
73
|
|
|
|
|
|
|
# ...post to your primary account *and* yet_another_screen_name |
74
|
|
|
|
|
|
|
post Hello, world! |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# ...post to your primary account and both secondary accounts |
77
|
|
|
|
|
|
|
post -fb Hello, universe! |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# ... post to my_other_screen name, only |
80
|
|
|
|
|
|
|
post -fbonly Hello, alternate reality. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 DESCRIPTION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This plugin allows cross-posting messages to multiple accounts. In |
85
|
|
|
|
|
|
|
configuration, you can provide an C<option> value. When used as an option to |
86
|
|
|
|
|
|
|
C<post>, your message will be cross-posted to your primary account and the |
87
|
|
|
|
|
|
|
secondary account with that C<option> value. If you do not provide an |
88
|
|
|
|
|
|
|
C<option> value, all messages are cross-posted to the secondary account. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
By appending C<only> to the C<option> value, your status will only be posted to |
91
|
|
|
|
|
|
|
the the account with that C<option> value. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
I use a configuration similar to the one in the synopsis to cross-post my |
94
|
|
|
|
|
|
|
Twitter status updates to Identi.ca, and optionally to Facebook. My Twitter |
95
|
|
|
|
|
|
|
screen name is C<semifor>. I created an account with screen name C<semifor_fb> |
96
|
|
|
|
|
|
|
and registered it with Twitter's Facebook application. In the C<twirc> |
97
|
|
|
|
|
|
|
configuration file, I assigned C<option> value C<fb> to the account. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
I created another secondary account with my Identi.ca screen name. In C<twirc> |
100
|
|
|
|
|
|
|
configuration, I used the C<net_twitter_options> to specify Identi.ca's |
101
|
|
|
|
|
|
|
C<apiurl>. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Now, when I post a normal status update, it is posted to C<semifor> on both |
104
|
|
|
|
|
|
|
Twitter and Identi.ca. If I include a C<-fb> option to post, my status update |
105
|
|
|
|
|
|
|
is posted to Twitter, Identi.ca, and Facebook. If I add a C<-fbonly> option to |
106
|
|
|
|
|
|
|
C<post>, my status update is only posted to the Facebook account. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 DEPRCATION NOTICE |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This module relies on username/password authentication, which Twitter dropped |
111
|
|
|
|
|
|
|
ages ago. The author isn't using this plugin, personally, and suspects no one |
112
|
|
|
|
|
|
|
else is, either. So, if you are using it, file an issue, or better---a pull |
113
|
|
|
|
|
|
|
request. Otherwise, it will get silently dropped in a future release. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 AUTHOR |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Marc Mims <mmims@cpan.org> |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 LICENSE |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Copyright (c) 2015 Marc Mims |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
You may distribute this code and/or modify it under the same terms as Perl itself. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |