]> git.donarmstrong.com Git - infobot.git/commitdiff
- we shifted args before using args[0]. fixed.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 3 Oct 2000 16:08:29 +0000 (16:08 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 3 Oct 2000 16:08:29 +0000 (16:08 +0000)
- 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

index a877586806baa10628d0f0fb0fb00b0847a80b50..7f65f99bfc5ea3ab1b25ac59817b9758d99062cb 100644 (file)
@@ -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;