From: pdbogen Date: Wed, 12 Sep 2007 20:42:09 +0000 (+0000) Subject: Memos are now stored to disk, and a usage message is printed if no arguments are... X-Git-Url: http://git.mmlx.us/?a=commitdiff_plain;h=23d85d003835022a83e10a8040cb6d87f886c7ab;p=destult.git Memos are now stored to disk, and a usage message is printed if no arguments are given. git-svn-id: https://www.cernu.us/~pdbogen/svn/destult2@25 088b83a4-0077-4247-935c-42ec02c2848b --- diff --git a/commands.yaml b/commands.yaml index 05fb878..91c913d 100644 --- a/commands.yaml +++ b/commands.yaml @@ -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 ", $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 --- 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" );