diff options
Diffstat (limited to 'bin/irc-ebooks-test')
-rwxr-xr-x | bin/irc-ebooks-test | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/bin/irc-ebooks-test b/bin/irc-ebooks-test new file mode 100755 index 0000000..e79f0da --- /dev/null +++ b/bin/irc-ebooks-test @@ -0,0 +1,64 @@ +#!/usr/bin/env perl + +# +# Test an IRC::Ebooks bot. +# +# Author: Tom Ryder <tom@sanctum.geek.nz> +# +package IRC::Ebooks::Test; + +# Force me to write this properly +use warnings; +use strict; +use utf8; +use autodie; + +# Everything's UTF-8 +use utf8::all; + +# Require Perl v5.14 +use 5.014; + +# Import required modules +use Carp; +use Config::Tiny; +use Getopt::Long::Descriptive; + +# Our custom module +use IRC::Ebooks; + +# Declare package version +our $VERSION = 0.1; + +# Set options +my ( $opt, $usage ) = describe_options( + 'irc-ebooks-feed %o [IRCLOGFILE ...]', + [ + 'config|c=s', + 'configuration file', + { default => '/etc/irc-ebooks.conf' }, + ], + [ 'help', 'print usage message and exit' ], +); + +# Give help if needed +if ( $opt->help ) { + print {*STDOUT} $usage->text + or carp q{Couldn't write to stdout}; + exit; +} + +# Read configuration +my $config = Config::Tiny->read( $opt->config ) + or croak sprintf q{Couldn't read configuration file %s}, $opt->config; + +# Create IRC::Ebooks object +my $irc_ebooks = IRC::Ebooks->new($config) + or croak q{Failed to create IRC::Ebooks object}; + +# Have him respond to each line of standard input +while (<>) { + chomp; + say $irc_ebooks->reply($_); +} + |