App-Twitch
view release on metacpan or search on metacpan
lib/App/Twitch.pm view on Meta::CPAN
use IO::All;
use String::Truncate qw(elide);
use utf8;
use Text::Keywords;
use Text::Keywords::Container;
use Text::Keywords::List;
use Text::Tweet;
use HTML::ExtractContent;
use Carp qw( croak );
use YAML qw( DumpFile );
# could be ... ah forget it :-P
use Net::Twitter;
our $VERSION ||= '0.0development';
before run => sub {
my $package = __PACKAGE__;
print <<"END_OF_INTRO";
_ _ _ _
| |_ _ _(_) |_ ___| |___
| _\\ \\ /\\ / / | __/ __| '_ \\
| |_ \\ V V /| | || (__| | | | $package $VERSION
\\__| \\_/\\_/ |_|\\__\\___|_| |_| Usage with --help
More information under http://search.cpan.org/perldoc/twitch
Commands:
start Start the twitch
stop Stop the running twitch
restart Restart the twitch, or start it up if not running
status Give current status of the twitch
END_OF_INTRO
};
after start => sub {
my $self = shift;
return unless $self->is_daemon;
# Required, elsewhere your POE goes nuts
POE::Kernel->has_forked if !$self->foreground;
POE::Kernel->run;
};
has '+pidbase' => (
default => sub { shift->tmpdir },
documentation => 'Directory for the pid file (default: tmpdir)',
);
has '+pidfile' => (
documentation => 'Filename for the pidfile (default: basedir/progname.pid)',
);
has '+progname' => (
default => sub { 'twitch' },
documentation => 'Name for the application, like configfile name base and so on (default: twitch)',
);
has '+foreground' => (
documentation => 'Run on the console and don\'t detach into background (default: off)',
);
has '+configfile' => (
default => sub { 'twitch.yml' },
documentation => 'Configuration file used for all those settings (default: twitch.yml)',
);
has 'configdir' => (
is => 'ro',
isa => 'Str',
default => sub { getcwd },
documentation => 'Directory for the keyword files and the feed file if given (default: current directory)',
);
has log_dispatch_conf => (
is => 'ro',
isa => 'HashRef',
lazy => 1,
required => 1,
traits => [ 'NoGetopt' ],
default => sub {
my $self = shift;
return {} if $self->no_logging;
my $format = '[%d] [%p] %m';
my $minlevel = $self->debug ? 'debug' : 'info';
if ($self->foreground || !$self->logfile) {
return {
class => 'Log::Dispatch::Screen',
min_level => $minlevel,
stderr => 1,
format => $format,
newline => 1,
}
} else {
return {
class => 'Log::Dispatch::File',
min_level => $minlevel,
filename => $self->configdir.'/'.$self->logfile,
mode => '>>',
format => $format,
newline => 1,
}
}
},
);
has consumer_key => (
isa => 'Str',
is => 'ro',
required => 1,
documentation => 'Consumer Key of your Twitter application',
);
has consumer_secret => (
isa => 'Str',
is => 'ro',
required => 1,
documentation => 'Consumer Secret of your Twitter application',
);
( run in 3.355 seconds using v1.01-cache-2.11-cpan-d8267643d1d )