Misc. ancient changes to xavierbot.
authorrjones <rjones>
Wed, 23 Jan 2008 15:44:46 +0000 (15:44 +0000)
committerrjones <rjones>
Wed, 23 Jan 2008 15:44:46 +0000 (15:44 +0000)
init
init.in
ocamlbotwrapper.c
xavierbot.pl
xavierbot.pl.in

diff --git a/init b/init
index 178497f..41bc2b2 100644 (file)
--- a/init
+++ b/init
@@ -1,5 +1,5 @@
 (* Initialise the toplevel environment. -*- tuareg -*-
- * $Id: init,v 1.7 2007/06/29 21:43:21 rjones Exp $
+ * $Id: init,v 1.8 2008/01/23 15:44:46 rjones Exp $
  * - Removes the Pervasives module and any dangerous functions.
  * - Loads just the modules we want to give access to, and just
  *   the functions within those modules that we want to give.
@@ -63,6 +63,7 @@ let _ = Int64.to_string
 let _ = List.length
 let _ = Nativeint.to_string
 let _ = Num.add_num
+let _ = Random.int
 let _ = Ratio.null_denominator
 let _ = Stack.create
 let _ = Str.regexp
diff --git a/init.in b/init.in
index bc41e72..a42d935 100644 (file)
--- a/init.in
+++ b/init.in
@@ -1,5 +1,5 @@
 (* Initialise the toplevel environment. -*- tuareg -*-
- * $Id: init.in,v 1.4 2007/06/29 19:39:13 rjones Exp $
+ * $Id: init.in,v 1.5 2008/01/23 15:44:46 rjones Exp $
  * - Removes the Pervasives module and any dangerous functions.
  * - Loads just the modules we want to give access to, and just
  *   the functions within those modules that we want to give.
@@ -63,6 +63,7 @@ let _ = Int64.to_string
 let _ = List.length
 let _ = Nativeint.to_string
 let _ = Num.add_num
+let _ = Random.int
 let _ = Ratio.null_denominator
 let _ = Stack.create
 let _ = Str.regexp
index 8557ed1..266bb17 100644 (file)
@@ -1,5 +1,5 @@
 /* -*- C -*-
- * $Id: ocamlbotwrapper.c,v 1.6 2007/06/29 21:43:21 rjones Exp $
+ * $Id: ocamlbotwrapper.c,v 1.7 2008/01/23 15:44:46 rjones Exp $
  * SUID wrapper around ocaml program.
  */
 
@@ -67,7 +67,10 @@ main ()
   setrlimit (RLIMIT_NOFILE, &lim);
 #endif
 #ifdef RLIMIT_NPROC
-  lim.rlim_cur = lim.rlim_max = 2;
+  /* If you want to run several instances of xavierbot, you may need
+   * to increase this limit.
+   */
+  lim.rlim_cur = lim.rlim_max = 4;
   setrlimit (RLIMIT_NPROC, &lim);
 #endif
 #ifdef RLIMIT_SIGPENDING
index 824c198..393c0eb 100755 (executable)
@@ -2,7 +2,7 @@
 # xavierbot : an OCaml interpreter IRC bot.
 # By Richard W.M. Jones <rich@annexia.org>.
 # This code is in the Public Domain.
-# $Id: xavierbot.pl,v 1.11 2007/07/05 12:43:14 rjones Exp $
+# $Id: xavierbot.pl,v 1.12 2008/01/23 15:44:46 rjones Exp $
 
 use strict;
 use POE qw(Component::IRC Wheel::Run);
@@ -108,10 +108,15 @@ sub irc_public
     if ($what =~ /^\s*xavierbot\b.*\bhelp\b/) {
        my $nick = (split /!/, $who)[0];
        $kernel->post ($sender => privmsg => $channel =>
-           "hello $nick, I am xavierbot 0.6, an OCaml toplevel");
+           "hello $nick, I am xavierbot 0.7, an OCaml toplevel");
        $kernel->post ($sender => privmsg => $channel => $_)
            foreach (@usage);
     }
+    elsif ($what =~ /^\s*xavierbot\b.*\brestart\b/) {
+       $sleeping = 0;
+       print STDOUT "got instruction to restart ...\n";
+       restart_toplevel ($heap->{ocaml});
+    }
     elsif (!$sleeping) {
        if (my ($stmt) = $what =~ m/^\s*([^\#].*;;)\s*$/) {
            $heap->{ocaml}->put ("$stmt\n");
@@ -128,11 +133,6 @@ sub irc_public
            $kernel->post ($sender => privmsg => $channel =>
                           "xavierbot wakes up");
        }
-       elsif ($what =~ /^\s*xavierbot\b.*\brestart\b/) {
-           $sleeping = 0;
-           print STDOUT "got instruction to restart ...\n";
-           restart_toplevel ($heap->{ocaml});
-       }
     }
     undef;
 }
index c0e0f82..f1a4cc8 100755 (executable)
@@ -2,7 +2,7 @@
 # xavierbot : an OCaml interpreter IRC bot.
 # By Richard W.M. Jones <rich@annexia.org>.
 # This code is in the Public Domain.
-# $Id: xavierbot.pl.in,v 1.8 2007/07/05 12:43:14 rjones Exp $
+# $Id: xavierbot.pl.in,v 1.9 2008/01/23 15:44:46 rjones Exp $
 
 use strict;
 use POE qw(Component::IRC Wheel::Run);
@@ -112,6 +112,11 @@ sub irc_public
        $kernel->post ($sender => privmsg => $channel => $_)
            foreach (@usage);
     }
+    elsif ($what =~ /^\s*xavierbot\b.*\brestart\b/) {
+       $sleeping = 0;
+       print STDOUT "got instruction to restart ...\n";
+       restart_toplevel ($heap->{ocaml});
+    }
     elsif (!$sleeping) {
        if (my ($stmt) = $what =~ m/^\s*([^\#].*;;)\s*$/) {
            $heap->{ocaml}->put ("$stmt\n");
@@ -128,11 +133,6 @@ sub irc_public
            $kernel->post ($sender => privmsg => $channel =>
                           "xavierbot wakes up");
        }
-       elsif ($what =~ /^\s*xavierbot\b.*\brestart\b/) {
-           $sleeping = 0;
-           print STDOUT "got instruction to restart ...\n";
-           restart_toplevel ($heap->{ocaml});
-       }
     }
     undef;
 }