-#!/usr/bin/perl -wT
+#!/usr/bin/perl -w
# 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.9 2007/06/29 21:43:21 rjones Exp $
+# $Id: xavierbot.pl,v 1.13 2008/02/13 17:35:32 rjones Exp $
use strict;
use POE qw(Component::IRC Wheel::Run);
+use Getopt::Long;
#----------------------------------------------------------------------
# Start of configuration.
my $nick = "xavierbot";
my $ircname = "Xavierbot"; # Printable name.
-#my $server = "chat.freenode.net";
-my $server = "devserv.devel.redhat.com";
+my $server = "chat.freenode.net";
my $port = 6667;
my $channel = "#ocaml";
# End of configuration.
#----------------------------------------------------------------------
-# Current state.
+
+# Command line args can override configuration.
+GetOptions ("nick=s" => \$nick,
+ "ircname=s" => \$ircname,
+ "server=s" => \$server,
+ "port=i" => \$port,
+ "channel=s" => \$channel)
+ or die "$0: GetOptions: $!";
# Simple flood protection. This counts number of lines received from
# the toplevel, and is reset when we send a line. If this exceeds
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.8, 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");
$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;
}