From: pdbogen Date: Wed, 12 Sep 2007 21:55:01 +0000 (+0000) Subject: TINYURL converts a URL to a TinyURL X-Git-Url: http://git.mmlx.us/?a=commitdiff_plain;h=30e1b1a01fd9a2ca49c116273c1481d01a30532b;p=destult.git TINYURL converts a URL to a TinyURL git-svn-id: https://www.cernu.us/~pdbogen/svn/destult2@26 088b83a4-0077-4247-935c-42ec02c2848b --- diff --git a/commands.yaml b/commands.yaml index 91c913d..5d72bbd 100644 --- a/commands.yaml +++ b/commands.yaml @@ -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 ); + } + }