- elsif ($what =~ /^\s*xavierbot\b.*\brestart\b/) {
- 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");
+ $flood_lim = 0;
+ }
+ elsif ($what =~ /^\s*xavierbot\b.*\b(sleep|shut|quiet)\b/) {
+ $sleeping = 1;
+ $kernel->post ($sender => privmsg => $channel =>
+ "xavierbot goes to sleep (do 'xavierbot wake' to wake)");
+ }
+ } else { # sleeping
+ if ($what =~ /^\s*xavierbot\b.*\bwake\b/) {
+ $sleeping = 0;
+ $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});
+ }