From 6a63172e2b49ea90a663bf5adaf18d6a609334e8 Mon Sep 17 00:00:00 2001 From: pdbogen Date: Mon, 3 Sep 2007 01:59:41 +0000 Subject: [PATCH] Added memo support. git-svn-id: https://www.cernu.us/~pdbogen/svn/destult2@13 088b83a4-0077-4247-935c-42ec02c2848b --- commands.yaml | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/commands.yaml b/commands.yaml index 9cc5c46..65ea710 100644 --- a/commands.yaml +++ b/commands.yaml @@ -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 ); + } -- 2.11.0