blob: 189ffb38c36d737d10295d5fb90d401a0b583dac (
plain) (
blame)
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
59
60
|
#!/usr/bin/env perl
#
# Run an IRC::Ebooks bot.
#
# Author: Tom Ryder <tom@sanctum.geek.nz>
#
package IRC::Ebooks::Run;
# 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};
# Run it
$irc_ebooks->run();
|