From 943568e6c3afcb7b66fc111425ad6762afb4af01 Mon Sep 17 00:00:00 2001 From: rjones Date: Thu, 5 Jul 2007 12:43:14 +0000 Subject: [PATCH] Added option parsing. --- README | 22 ++++++++++++++++++++++ xavierbot.pl | 15 +++++++++++---- xavierbot.pl.in | 15 +++++++++++---- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/README b/README index ea53c40..78e0171 100644 --- a/README +++ b/README @@ -35,3 +35,25 @@ Either: sudo make install or: sudo make permissions + +RUNNING --------------------------------------------- + +You need to do either sudo make install or sudo make permissions in +order to create the suid wrapper program (see previous section). + +To run, simply do: + + ./xavierbot.pl + +Default configuration comes from the top of the file xavierbot.pl.in. +You may also override the defaults on the command line. For example: + + ./xavierbot.pl --server irc.example.com + +The options are: + + --nick Change nick (default: xavierbot) + --ircname Change printable name (default: Xavierbot) + --server Change server (default: chat.freenode.net) + --port Change port (default: 6667) + --channel Change channel (default: #ocaml) diff --git a/xavierbot.pl b/xavierbot.pl index d07ac41..824c198 100755 --- a/xavierbot.pl +++ b/xavierbot.pl @@ -1,11 +1,12 @@ -#!/usr/bin/perl -wT +#!/usr/bin/perl -w # xavierbot : an OCaml interpreter IRC bot. # By Richard W.M. Jones . # This code is in the Public Domain. -# $Id: xavierbot.pl,v 1.10 2007/06/29 21:44:02 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. @@ -13,13 +14,19 @@ use POE qw(Component::IRC Wheel::Run); my $nick = "xavierbot"; my $ircname = "Xavierbot"; # Printable name. my $server = "chat.freenode.net"; -#my $server = "devserv.devel.redhat.com"; 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 diff --git a/xavierbot.pl.in b/xavierbot.pl.in index 8f01f0b..c0e0f82 100755 --- a/xavierbot.pl.in +++ b/xavierbot.pl.in @@ -1,11 +1,12 @@ -#!/usr/bin/perl -wT +#!/usr/bin/perl -w # xavierbot : an OCaml interpreter IRC bot. # By Richard W.M. Jones . # This code is in the Public Domain. -# $Id: xavierbot.pl.in,v 1.7 2007/06/29 21:44:02 rjones Exp $ +# $Id: xavierbot.pl.in,v 1.8 2007/07/05 12:43:14 rjones Exp $ use strict; use POE qw(Component::IRC Wheel::Run); +use Getopt::Long; #---------------------------------------------------------------------- # Start of configuration. @@ -13,13 +14,19 @@ use POE qw(Component::IRC Wheel::Run); my $nick = "xavierbot"; my $ircname = "Xavierbot"; # Printable name. my $server = "chat.freenode.net"; -#my $server = "devserv.devel.redhat.com"; 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 -- 1.8.3.1