A command to toggle URL trapping, and tweak the regex used on same.
authorpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Sat, 13 Aug 2011 04:33:32 +0000 (04:33 +0000)
committerpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Sat, 13 Aug 2011 04:33:32 +0000 (04:33 +0000)
git-svn-id: https://www.cernu.us/~pdbogen/svn/destult2@115 088b83a4-0077-4247-935c-42ec02c2848b

commands.yaml

index d10a198..4819f72 100644 (file)
@@ -4,6 +4,24 @@ DIE: |-
     exit;
   }
 
+TRAP: |-
+  sub {
+    my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+    my $str = "";
+    for my $s (@{$heap->{ "servers" }}) {
+      if( $s->{ "ssid" } == $src ) {
+        if( $s->{ "trapEnabled" } ) {
+          $s->{ "trapEnabled" } = 0;
+          $kernel->post( $src, $replypath, "URL trapping now DISABLED. D:", $dest );
+        } else {
+          $s->{ "trapEnabled" } = 1;
+          $kernel->post( $src, $replypath, "URL trapping now enabled. :)", $dest );
+        }
+      }
+    }
+    return;
+  }
+
 LINK: |-
   sub {
     my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
@@ -1943,7 +1961,7 @@ TITLE: |-
     my $res = $ua->request( $req );
     if( $res->is_success ) {
       my $content = $res->content;
-      if( $content =~ /<title>(.*?)<\/title>/si ) {
+      if( $content =~ /<title[^>]*>(.*?)<\/title>/si ) {
         use HTML::Entities;
         my $title = decode_entities( $1 );
         $title =~ s/[[:space:]]+/ /gs;