Allow random to accept comma-delimited lists, but retain old behavior in case of...
authorpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Mon, 12 Dec 2011 16:06:40 +0000 (16:06 +0000)
committerpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Mon, 12 Dec 2011 16:06:40 +0000 (16:06 +0000)
git-svn-id: https://www.cernu.us/~pdbogen/svn/destult2@121 088b83a4-0077-4247-935c-42ec02c2848b

commands.yaml

index be831e0..0b9bf10 100644 (file)
@@ -732,7 +732,12 @@ ADVERTISE: |-
 RANDOM: |-
   sub {
     my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
-    my @opts = split( / /, $what );
+    my @opts;
+    if( $what =~ m/,/ ) {
+       @opts = split( /\s*,\s*/, $what );
+    } else {
+       @opts = split( / /, $what );
+    }
     if( $#opts >= 0 ) {
       $kernel->post( $src, $replypath, $opts[ int( rand( $#opts+1 ) ) ], $dest );
     }