Added option parsing.
[xavierbot.git] / xavierbot.pl
index a621a4e..824c198 100755 (executable)
@@ -1,25 +1,32 @@
-#!/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.11 2007/07/05 12:43:14 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