Use HTML::Entities to decode entities from urban dictionary responses. Also implememn...
authorpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Wed, 11 Feb 2009 20:40:07 +0000 (20:40 +0000)
committerpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Wed, 11 Feb 2009 20:40:07 +0000 (20:40 +0000)
git-svn-id: https://www.cernu.us/~pdbogen/svn/destult2@84 088b83a4-0077-4247-935c-42ec02c2848b

cmdaccess.yaml
commands.yaml

index a1d108b..05c94cc 100644 (file)
@@ -7,6 +7,7 @@ CMDACCESS: 2
 CONFIG: 2
 DECLASSIFY: 2
 DEFINE: 1
+DICTCLEAN: 2
 DIE: 2
 FLUSHURLS: 1
 IGNORE: 2
index 310516a..b7548dd 100644 (file)
@@ -430,6 +430,13 @@ LISTKEYS: |-
     $kernel->post( $src, $replypath, $reply, $dest );
   }
 
+DICTCLEAN: |-
+  sub {
+    my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+    $heap->{ 'DICT_cache' } = {};
+    $kernel->post( $src, $replypath, "Cleaned.", $dest );
+  }
+
 DICT: |-
   sub {
     require WWW::Search;
@@ -464,6 +471,7 @@ DICT: |-
     }
   
     if( $dict =~ m/^urban/i ) {
+      use HTML::Entities;
       print( "DICT: Urban Dictionary", "\n" );
   
       my $key = "84d324f8a5fcae301ec4aefcd258dff2";
@@ -497,6 +505,7 @@ DICT: |-
         print( "DICT: Backend reports $hits hit".($hits==1?"":"s"), "\n" );
       }
       my $response = $result->{ 'word' }.": ".$result->{ 'definition' };
+      $response = decode_entities( $response );
       $response =~ s/\n/ /g;
       print( "DICT: Fetched result\n" );
       $heap->{ 'DICT_cache' }->{ 'URBAN' }->{ "$num.$what" } = $response;