forked from rcaputo/bot-pastebot
/
pastebot.perl
executable file
·73 lines (57 loc) · 1.19 KB
/
pastebot.perl
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
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/perl -w
# $Id$
use strict;
use lib '.';
use File::Basename;
use Env;
# Old way - hard coded paths. Now the library location
# is told in /etc/pastebot/pastebot.lib and read upon startup.
#
# use lib '/usr/share/pastebot';
# use POE ;
# use Server::Web ;
# use Client::IRC ;
# The last file overrides. This file can tell where the libraries
# by including statement:
#
# push @INC, '/path/to/pastebotlibs';
# Places where the libraries may be found.
my @CONFIG_FILE = qw(
$HOME/.pastebot.lib
/etc/pastebot/pastebot.lib
.
);
# Libraries we need.
my @LIBS = qw(
Perl::Tidy
POE
Server::Web
Client::IRC
);
sub Error ($ $) {
my ($lib, $msg) = @_;
$msg =~ s/ in \@INC.*//s;
my $liberr = << "EOF";
$0 Error while loading $lib: $msg
Please make sure that the following libraries
have been installed:
@LIBS
EOF
die "While loading library [$lib]\n$liberr";
}
sub LoadLibraries () {
push @INC, dirname $0;
for my $config ( @CONFIG_FILE ) {
if ( -f $config ) {
require $config or die $!;
}
}
# Run time loading
for my $lib ( @LIBS ) {
eval "use $lib;" ;
$@ and Error($lib, $@);
}
}
LoadLibraries();
POE::Kernel->run();
exit 0;