-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcvnircbot.pl
executable file
·44 lines (34 loc) · 959 Bytes
/
cvnircbot.pl
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
#!/usr/bin/perl
use strict;
use warnings;
use FindBin;
use lib $FindBin::Bin;
use CanvonIRCBot;
my $conffile = "$ENV{HOME}/.cvnircbot/cvnircbotrc";
my $config;
(my $basename = $0) =~ s#/.*/##;
while (scalar(@ARGV) > 0) {
my $arg = shift;
if ($arg !~ /^-/) {
unshift(@ARGV, $arg);
last;
}
if ($arg =~ /^(-\?|-h|--help|--usage)$/) {
print("Usage: $basename [--config-file=CONFFILE]\n");
exit(0);
}
elsif ($arg =~ /^--config-file=(.*)$/) {
$conffile = $1;
}
else {
die("$basename: Invalid argument \"$arg\"\n");
}
}
scalar(@ARGV) == 0 or die("$basename: Invalid arguments\n");
unless ($config = do $conffile) {
die "$basename: couldn't parse $conffile: $@\n" if $@;
die "$basename: couldn't do $conffile: $!\n" unless defined $config;
die "$basename: couldn't run $conffile\n" unless $config;
}
my $bot = CanvonIRCBot->new(@$config);
$bot->run();