Plenty of bugs. Or paper. Whatever. Change response messages from DEFINE
authorpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Mon, 25 Aug 2008 16:44:43 +0000 (16:44 +0000)
committerpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Mon, 25 Aug 2008 16:44:43 +0000 (16:44 +0000)
git-svn-id: https://www.cernu.us/~pdbogen/svn/destult2@54 088b83a4-0077-4247-935c-42ec02c2848b

commands.yaml

index 13584e3..44336ca 100644 (file)
@@ -329,11 +329,11 @@ DEFINE: |-
       if( $predicate ) {
         $heap->{ 'db' }->{ uc( $subj ) } = $predicate;
         DumpFile( "factoids.yaml", $heap->{ 'db' } );
-        $kernel->post( $src, $replypath, "Okay, $who.", $dest );
+        $kernel->post( $src, $replypath, "$who: Factoid '$subj' defined as '$predicate'", $dest );
       } else {
         delete $heap->{ 'db' }->{ uc( $subj ) } if exists $heap->{ 'db' }->{ uc( $subj ) };
         DumpFile( "factoids.yaml", $heap->{ 'db' } );
-        $kernel->post( $src, $replypath, "Okay, $who.", $dest );
+        $kernel->post( $src, $replypath, "$who: Factoid '$subj' removed", $dest );
       }
     } else {
       $kernel->post( $src, $replypath, "Invalid subject.", $dest );
@@ -1478,18 +1478,16 @@ SHORTEN: |-
   sub {
     my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
     my( $service, $url ) = split( / /, $what, 2 );
-    $service =~ s/[^a-z]//gi;
-    if( length $url ) {
-      eval "use WWW::Shorten::$service";
-      if( $@ ) {
-       $kernel->post( $src, $replypath, "Loading 'WWW::Shorten::$service' failed: $@", $dest );
-       return;
-      }
-    } else {
+    if( ! length $url ) {
       $url = $service;
-      use WWW::Shorten::TinyURL;
+      $service = "SnipURL";
+    }
+    $service =~ s/[^a-z]//gi;
+    eval "use WWW::Shorten::$service";
+    if( $@ ) {
+       $kernel->post( $src, $replypath, "Loading 'WWW::Shorten::$service' failed: $@", $dest );
+       return;
     }
-    my( $kernel, $heap, $who, $url, $src, $dest, $replypath ) = @_;
     if( !exists( $heap->{ 'urls' } ) ) {
       $heap->{ 'urls' } = {};
     }
@@ -1497,9 +1495,13 @@ SHORTEN: |-
       my @arr = @{ $heap->{ 'urls' }->{ uc( $url ) } };
       $kernel->post( $src, $replypath, $arr[2]." [first: ".$arr[0]."/".$arr[1]."]", $dest );
     } else {
-      my $url = makeashorterlink( $url ) or return;
-      $heap->{ 'urls' }->{ uc( $url ) } = [ $who, $dest->{ 'dest' }, $url ];
-      $kernel->post( $src, $replypath, "$url [$who]", $dest );
+      my $url = makeashorterlink( $url );
+      if( defined $url ) {
+        $heap->{ 'urls' }->{ uc( $url ) } = [ $who, $dest->{ 'dest' }, $url ];
+        $kernel->post( $src, $replypath, "$url [$who]", $dest );
+      } else {
+        $kernel->post( $src, $replypath, "Shortening URL failed.", $dest );
+      }
     }
   }
 FLUSHURLS: |-