You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

infobot 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/usr/bin/perl
  2. # infobot -- copyright kevin lenzo (c) 1997-infinity
  3. # no warrantee expressed or implied. terms as the
  4. # license for X11R6 when needed.
  5. BEGIN {
  6. $VER_MAJ = 0;
  7. $VER_MIN = 45;
  8. $VER_MOD = 3;
  9. $version = "infobot $VER_MAJ\.$VER_MIN\.$VER_MOD [Wurm]";
  10. }
  11. BEGIN {
  12. $filesep = '/';
  13. # set this to the absolute path if you need it; especially
  14. # if . is not in your path
  15. $param{'basedir'} = ($0 =~ /(.*)$filesep/) ? $1 : '.';
  16. # $infobot_base_dir = '/usr/local/lib/infobot';
  17. # change this next line if you run a local instance of
  18. # an infobot and use the code from the main location.
  19. # the 'files' directory contains infobot.config and
  20. # infobot.users, among other things.
  21. $param{'confdir'} = "$param{basedir}${filesep}conf";
  22. # everything is loaded, then the variables that
  23. # you want to set will override the defaults; this
  24. # is why all these requires are here.
  25. $param{'srcdir'} = $param{'basedir'}.$filesep."src";
  26. opendir DIR, $param{'srcdir'}
  27. or die "can't open source directory $param{srcdir}: $!";
  28. while ($file = readdir DIR) {
  29. next unless $file =~ /\.pl$/;
  30. require "$param{srcdir}$filesep$file";
  31. }
  32. closedir DIR;
  33. $param{'extradir'} = $param{'basedir'}.$filesep."extras";
  34. opendir DIR, $param{'extradir'}
  35. or die "can't open extras directory $param{extradir}: $!";
  36. while ($file = readdir DIR) {
  37. next unless $file =~ /\.pl$/;
  38. require "$param{extradir}$filesep$file";
  39. }
  40. closedir DIR;
  41. }
  42. # get the command line arguments
  43. &getArgs();
  44. # initialize everything
  45. &setup();
  46. # launch the irc event loop
  47. &irc();
  48. exit 0; # just so you don't look farther down in this file :)
  49. # --- support routines
  50. sub usage {
  51. print "\n";
  52. print " usage: $0 [-h] [<paramfile1> [<pf2> ...]]\n";
  53. print "\n";
  54. print " -h this message\n";
  55. print "\n";
  56. }
  57. sub getArgs {
  58. if (@ARGV) {
  59. while (@ARGV) {
  60. my $arg = shift @ARGV;
  61. if ($arg =~ s/^-//) {
  62. # switchies
  63. if ($arg eq 'i') {
  64. # go into irc mode despite db setting
  65. $overrideMode = 'IRC';
  66. } else {
  67. # -h is in here by default
  68. &usage;
  69. exit(1);
  70. }
  71. } else {
  72. # no switchie. currently assumed to be
  73. # a paramfile by default
  74. push @paramfiles, $arg;
  75. }
  76. }
  77. } else {
  78. @paramfiles = ();
  79. }
  80. }
  81. 1;