From d08fd520df5d27b2d1a6efd94776f7332a6d591f Mon Sep 17 00:00:00 2001 From: dms Date: Tue, 3 Oct 2000 16:08:29 +0000 Subject: [PATCH] - we shifted args before using args[0]. fixed. - fixed broken 'convert' cmd. git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@155 c11ca15a-4712-0410-83d8-924469b57eb5 --- src/CommandStubs.pl | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/CommandStubs.pl b/src/CommandStubs.pl index a877586..7f65f99 100644 --- a/src/CommandStubs.pl +++ b/src/CommandStubs.pl @@ -31,22 +31,22 @@ sub addCmdHook { # RUN IF ADDRESSED. sub parseCmdHook { - my @args = split(' ', $message); + my @args = split(' ', $message); + my $cmd = shift(@args); &shmFlush(); foreach (keys %cmdhooks) { my $ident = $_; - next unless ($args[0] =~ /^$ident$/i); - shift(@args); # just gotta do it. + next unless ($cmd =~ /^$ident$/i); - &DEBUG("pCH: $args[0] matched $ident"); + &DEBUG("pCH: $cmd matched $ident"); my %hash = %{ $cmdhooks{$ident} }; ### DEBUG. foreach (keys %hash) { - &DEBUG(" $args[0]\->$_ => '$hash{$_}'."); + &DEBUG(" $cmd->$_ => '$hash{$_}'."); } ### HELP. @@ -483,12 +483,13 @@ sub cookie { } sub convert { - my (@args) = @_; - my ($from,$to); - ($from,$to) = ($args[0],$args[2]) if ($args[1] =~ /^from$/i); - ($from,$to) = ($args[2],$args[0]) if ($args[1] =~ /^to$/i); + my $arg = join(' ',@_); + my ($from,$to) = ('',''); - if (!defined $from or !defined $to or $to eq "" or $from eq "") { + ($from,$to) = ($1,$2) if ($arg =~ /^(.*?) to (.*)$/i); + ($from,$to) = ($2,$1) if ($arg =~ /^(.*?) from (.*)$/i); + + if (!$to or !$from) { &msg($who, "Invalid format!"); &help("convert"); return $noreply; -- 2.39.5