Added memo support.
authorpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Mon, 3 Sep 2007 01:59:41 +0000 (01:59 +0000)
committerpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Mon, 3 Sep 2007 01:59:41 +0000 (01:59 +0000)
git-svn-id: https://www.cernu.us/~pdbogen/svn/destult2@13 088b83a4-0077-4247-935c-42ec02c2848b

commands.yaml

index 9cc5c46..65ea710 100644 (file)
@@ -1301,3 +1301,50 @@ GROUPHUG: |-
       $kernel->post( $src, $replypath, "Failed to fetch list of hugs.", $dest );
     }
   }
+
+CHEKCMEMO: |-
+  sub {
+    my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+    if( !exists( $heap->{ 'memo' } ) ) {
+      $heap->{ 'memo' } = {};
+    }
+    if( !exists( $heap->{ 'memo' }->{ uc( $who ) } ) ) {
+      $kernel->post( $src, $replypath, "No memos found.", $dest );
+      return 1;
+    }
+    my @memos = @{ $heap->{ 'memo' }->{ uc( $who ) } };
+    for my $memo( @memos ) {
+       my @memo = @$memo;
+        my $t = time - $memo[1];
+        my $response;
+        if( $t > 86400 ) {
+          $response .= floor($t/86400)."d ";
+          $t = $t % 86400;
+        }
+        if( $t > 3600 ) {
+          $response .= floor($t/3600)."h ";
+          $t = $t % 3600;
+        }
+        if( $t > 60 ) {
+          $response .= floor($t/60)."m ";
+          $t = $t % 60;
+        }
+        $response .= $t."s ago";
+       $kernel->post( $src, $replypath, "From: ".$memo[0].", $response ago: ".$memo[2], $dest );
+    }
+    delete $heap->{ 'memo' }->{ uc( $who ) };
+  }
+
+MEMO: |-
+  sub {
+    my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+    my( $rec, $msg ) = split( / /, $what, 2 );
+       if( !exists( $heap->{ 'memo' } ) ) {
+               $heap->{ 'memo' } = {};
+       }
+       if( !exists( $heap->{ 'memo' }->{ uc( $rec ) } ) ) {
+               $heap->{ 'memo' }->{ uc( $rec ) } = [];
+       }
+       push @{ $heap->{ 'memo' }->{ uc( $rec ) } }, [ $who, time, $msg ];
+       $kernel->post( $src, $replypath, "Memo left for $rec.", $dest );
+  }