Dear Home Owner, このページをアンテナに追加 RSSフィード

 | 

2006-02-28

Plagger::Plugin::Publish::Hotline  Plagger::Plugin::Publish::Hotline - Dear Home Owner, を含むブックマーク はてなブックマーク -  Plagger::Plugin::Publish::Hotline - Dear Home Owner,  Plagger::Plugin::Publish::Hotline - Dear Home Owner, のブックマークコメント

lib/Plagger/Plugin/Publish/Hotline.pm

package Plagger::Plugin::Publish::Hotline;
use strict;
use base qw( Plagger::Plugin );

use Encode;
use Net::Hotline::Client;

sub register {
    my($self, $context) = @_;
    $context->register_hook(
        $self,
        'publish.feed' => \&feed,
    );
}

sub feed {
    my($self, $context, $args) = @_;

    my $hlc = new Net::Hotline::Client;
    $hlc->connect($self->conf->{host}) or $context->error("Can't connect hotline server: $!");
    $hlc->login(
	Login    => $self->conf->{login}    || '',
	Password => $self->conf->{password} || '',
	Nickname => $self->conf->{nickname} || 'Plagger Bot',
	Icon     => $self->conf->{icon}     || 128) or $context->error("Login failed: $!");

    $context->log(info => "writing output to hotline server.");
    for my $entry($args->{feed}->entries) {
	$hlc->chat($self->convert(join("\n", ($entry->title, $entry->permalink))));
    }
    $hlc->disconnect();
}

sub convert {
    my ($self, $str) = @_;
    utf8::decode($str) unless utf8::is_utf8($str);
    return encode($self->conf->{encode}, $str);
}

1;

__END__

=head1 NAME

Plagger::Plugin::Publish::Hotline - Publish to hotline server

=head1 SYNOPSIS

  - module: Publish::Hotline
    config:
      host: xxx.xx.xx.xx
      login: login
      password: password
      nickname: youpy
      icon: 128
      encode: shift_jis

=head1 DESCRIPTION

This plugin publish feed updates to hotline server.

=head1 AUTHOR

id:youpy

=head1 SEE ALSO

L<Plagger>

=cut

Screenshot

http://f.hatena.ne.jp/images/fotolife/y/youpy/20060228/20060228014339.png

Demonstrate at:

hotline://69.10.142.65 (It's not my server, so behave yourself)

トラックバック - http://subtech.g.hatena.ne.jp/youpy/20060228
 |