OSDN Git Service

add Feed creation worker (only tested json feed yet)
[mubot4fb/mubot4fb.git] / lib / Mubot4FB / TweetWorker.pm
1 #!/usr/bin/perl
2 #
3 # Copyright (c) 2012 ISHIKAWA Mutsumi <ishikawa@hanzubon.jp>
4 # This program is covered by the GNU General Public License 2
5 #
6 package Mubot4FB::TweetWorker;
7
8 use strict;
9 use utf8;
10
11 use Data::Dumper;
12
13 use base 'TheSchwartz::Worker';
14 use Mubot4FB::Tweet;
15
16 sub sighandler {
17         warn "caught signal @_\n";
18         no warnings 'redefine';
19         *TheSchwartz::work_once = sub { exit };
20 }
21
22 sub compose_text {
23         my ($me, $args) = @_;
24
25         return $args->{submitter} . '曰く、'.$args->{prefix}.' '.$args->{comment};
26 }
27
28 sub work {
29         my ($me, $job) = @_;
30
31         $SIG{HUP} = $SIG{INT} = $SIG{TERM} = \&sighandler;
32
33         if ($job ->arg->{_command} eq 'remove') {
34         } else {
35                 my $text = $me->compose_text($job->arg);
36                 my $uri = $me->post_uri($job->{arg}->{post_id});
37         }
38         $job->completed();
39 }