/
to-plurk
executable file
·58 lines (41 loc) · 1.27 KB
/
to-plurk
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env perl
use common::sense;
package PlurkPoster;
use Object::Tiny qw(username password);
use WWW::Mechanize;
sub post {
my ($self, @content) = @_;
my $ua = WWW::Mechanize->new;
$ua->get('http://www.plurk.com/m/login');
$ua->submit_form(with_fields => { username => $self->username, password => $self->password });
for(@content) {
$ua->submit_form(with_fields => { content => $_ });
}
}
package main;
use common::sense;
use encoding 'utf8';
use YAML qw(LoadFile);
use Getopt::Std;
my %opts;
getopt('c', \%opts);
die "Usage: $0 -c plurk.yml\n" unless $opts{c};
my $config = LoadFile($opts{c}) or die "Fail to load plurk.yml\n";
my $pp = PlurkPoster->new(
username => $config->{username},
password => $config->{password},
);
local undef $/;
my @content = split(/\n+/, <>);
$pp->post(@content);
# $pp->post($content);
=head1 NAME / USAGE / SYNOPSIS / DESCRIPTION
This program send whatever read from STDIN to plurk.com:
echo "Lorem ipsum is good" | to-plurk -c plurk.yml
Best for shell scripting.
=head1 COPYRIGHT
Copyright 2010 by Kang-min Liu, <gugod@gugod.org>
This program is free software; you can redistribute it a nd/or modify
it under the same terms as Perl itself.
See L<http://www.perl.com/perl/misc/Artistic.html>
=cut