Memos are now stored to disk, and a usage message is printed if no arguments are...
authorpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Wed, 12 Sep 2007 20:42:09 +0000 (20:42 +0000)
committerpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Wed, 12 Sep 2007 20:42:09 +0000 (20:42 +0000)
git-svn-id: https://www.cernu.us/~pdbogen/svn/destult2@25 088b83a4-0077-4247-935c-42ec02c2848b

commands.yaml
core.pl

index 05fb878..91c913d 100644 (file)
@@ -1343,11 +1343,16 @@ CHECKMEMO: |-
        $kernel->post( $src, $replypath, "From: ".$memo[0].", $response ago: ".$memo[2], $dest );
     }
     delete $heap->{ 'memo' }->{ uc( $who ) };
+       DumpFile( "memos.yaml", $heap->{ 'memo' } );
   }
 
 MEMO: |-
   sub {
     my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+    if( ($what =~ s/ / /g) < 1 ) {
+      $kernel->post( $src, $replypath, "Usage: MEMO <recipient> <message>", $dest );
+      return;
+    }
     my( $rec, $msg ) = split( / /, $what, 2 );
        if( !exists( $heap->{ 'memo' } ) ) {
                $heap->{ 'memo' } = {};
@@ -1356,5 +1361,6 @@ MEMO: |-
                $heap->{ 'memo' }->{ uc( $rec ) } = [];
        }
        push @{ $heap->{ 'memo' }->{ uc( $rec ) } }, [ $who, time, $msg ];
+       DumpFile( "memos.yaml", $heap->{ 'memo' } );
        $kernel->post( $src, $replypath, "Memo left for $rec.", $dest );
   }
diff --git a/core.pl b/core.pl
index 904de3f..63b6249 100644 (file)
--- a/core.pl
+++ b/core.pl
@@ -62,6 +62,13 @@ sub on_start {
                print( "CORE: No commands found.\n" );
        }
 
+       if( -e "memos.yaml" ) {
+               $heap->{ 'memo' } = \%{ LoadFile( "memos.yaml" ) };
+               print( "CORE: Memos loaded.\n" );
+       } else {
+               print( "CORE: No memos found.\n" );
+       }
+
        if( -e "factoids.yaml" ) {
                $heap->{ 'db' } = \%{ LoadFile( "factoids.yaml" ) };
                print( "CORE: Factoids loaded.\n" );