TINYURL converts a URL to a TinyURL
authorpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Wed, 12 Sep 2007 21:55:01 +0000 (21:55 +0000)
committerpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Wed, 12 Sep 2007 21:55:01 +0000 (21:55 +0000)
git-svn-id: https://www.cernu.us/~pdbogen/svn/destult2@26 088b83a4-0077-4247-935c-42ec02c2848b

commands.yaml

index 91c913d..5d72bbd 100644 (file)
@@ -1364,3 +1364,20 @@ MEMO: |-
        DumpFile( "memos.yaml", $heap->{ 'memo' } );
        $kernel->post( $src, $replypath, "Memo left for $rec.", $dest );
   }
+
+TINYURL: |-
+  sub {
+    use WWW::Shorten::TinyURL;
+    my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+    if( !exists( $heap->{ 'urls' } ) ) {
+      $heap->{ 'urls' } = {};
+    }
+    if( exists( $heap->{ 'urls' }->{ uc( $what ) } ) ) {
+      my @arr = @{ $heap->{ 'urls' }->{ uc( $what ) } };
+      $kernel->post( $src, $replypath, $arr[2]." [first: ".$arr[0]."/".$arr[1]."]", $dest );
+    } else {
+      my $url = makeashorterlink( $what );
+      $heap->{ 'urls' }->{ uc( $what ) } = [ $who, $dest, $url ];
+      $kernel->post( $src, $replypath, "$url [$who]", $dest );
+    }
+  }