3 # infobot -- copyright kevin lenzo (c) 1997-1999
4 # blootbot -- copyright david sobon (c) 1999-infinity
7 use vars qw($bot_base_dir $bot_src_dir $bot_misc_dir
8 $bot_pid $memusage %param
12 # set this to the absolute path if you need it; especially
13 # if . is not in your path
16 $bot_src_dir = "$bot_base_dir/src";
17 $bot_misc_dir = "$bot_base_dir/files";
20 require "$bot_src_dir/logger.pl";
21 require "$bot_src_dir/core.pl";
22 require "$bot_src_dir/interface.pl";
23 require "$bot_src_dir/modules.pl";
25 # load the configuration (params) file.
28 &showProc(); # to get the first value.
29 &status("Initial memory usage: $memusage kB");
32 &loadFactoidsModules();
35 &status("Memory usage after loading modules: $memusage kB");
38 # prevent duplicate processes of the same bot
41 # initialize everything
42 &startup(); # first time initialization.
45 if (!&IsParam("Interface") or $param{'Interface'} =~ /IRC/) {
46 # launch the irc event loop
52 exit 0; # just so you don't look farther down in this file :)
54 # --- support routines
57 # add arguments, basically '-h' and '--help', heh.
63 my $file = $file{PID};
66 open(PIDFILE,$file) or die "error: cannot open $file.";
67 my $thispid = <PIDFILE> || "NULL\n";
71 if ($thispid =~ /^\D$/) {
72 &staus("warning: pidfile is invalid; wiping out.");
74 if ( -d "/proc/$thispid/") {
75 &ERROR("bot is already running from this directory.");
76 &ERROR("if this is incorrect, erase '*.pid'.");
77 &ERROR("verify with 'ps -axu | grep $thispid'.");
80 &status("warning: stale $file found; wiping.");
85 open(PIDFILE,">$file") or die "error: cannot write to $file.";
86 print PIDFILE "$pid\n";