root/lang/perl/plagger/lib/Plagger/Plugin/Publish/Jaiku.pm

Revision 459, 1.8 kB (checked in by mattn, 14 months ago)

lang/perl/plagger/lib/Plagger/Publish/Jaiku.pm: added optional key 'userkey_password' for crypt.

Line 
1package Plagger::Plugin::Publish::Jaiku;
2use strict;
3use base qw( Plagger::Plugin );
4
5use Encode;
6use Net::Jaiku;
7use Time::HiRes qw(sleep);
8
9sub register {
10    my($self, $context) = @_;
11    $context->register_hook(
12        $self,
13        'publish.entry' => \&publish_entry,
14        'plugin.init'   => \&initialize,
15    );
16}
17
18sub initialize {
19    my($self, $context) = @_;
20    my %opt = (
21        username => $self->conf->{username},
22        userkey => $self->conf->{userkey},
23    );
24    $opt{userkey} = $self->conf->{userkey_password} unless($self->conf->{userkey});
25    $self->{jaiku} = Net::Jaiku->new(%opt);
26}
27
28sub publish_entry {
29    my($self, $context, $args) = @_;
30
31    my $body = $self->templatize('jaiku.tt', $args);
32    # TODO: FIX when Summary configurable.
33    if ( length($body) > 159 ) {
34        $body = substr($body, 0, 159);
35    }
36    $context->log(info => "Updating Jaiku status to '$body'");
37    $self->{jaiku}->setPresence( message => encode_utf8($body) ) or $context->error("Can't update jaiku status");
38
39    my $sleeping_time = $self->conf->{interval} || 15;
40    $context->log(info => "sleep $sleeping_time.");
41    sleep( $sleeping_time );
42}
43
441;
45__END__
46
47=head1 NAME
48
49Plagger::Plugin::Publish::Jaiku - Update your status with feeds
50
51=head1 SYNOPSIS
52
53  - module: Publish::Jaiku
54    config:
55      username: jaiku-id
56      userkey: jaiku-apikey
57
58=head1 DESCRIPTION
59
60This plugin sends feed entries summary to your jaiku account status.
61
62=head1 CONFIG
63
64=over 4
65
66=item username
67
68Jaiku username. Required.
69
70=item userkey
71
72Jaiku apikey.
73use userkey_password instead of userkey if you want to crypt it.
74
75=item userkey_password
76
77Optional for userkey.
78
79=item interval
80
81Optional.
82
83=item interval
84
85Optional.
86
87=item timeout
88
89Optional.
90
91=back
92
93=head1 AUTHOR
94
95Yasuhiro Matsumoto
96
97=head1 SEE ALSO
98
99L<Plagger>, L<Net::Jaiku>
100
101=cut
Note: See TracBrowser for help on using the browser.