Notify the user if they have memos waiting if they're unidentified, isntead of remain...
authorpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Mon, 14 Sep 2009 16:57:48 +0000 (16:57 +0000)
committerpdbogen <pdbogen@088b83a4-0077-4247-935c-42ec02c2848b>
Mon, 14 Sep 2009 16:57:48 +0000 (16:57 +0000)
git-svn-id: https://www.cernu.us/~pdbogen/svn/destult2@106 088b83a4-0077-4247-935c-42ec02c2848b

commands.yaml
core.pl
irc.pl

index eceac67..8c7f463 100644 (file)
@@ -282,6 +282,10 @@ PASSWORD: |-
   sub {
     use Digest::MD5 qw( md5_hex );
     my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+    if( $what !~ /[^ ]+ [^ ]+/ ) {
+      $kernel->post( $src, $replypath, "Usage: PASSWORD <old password> <new password>", $dest );
+      return;
+    }
     my( $old, $new ) = split( / /, $what, 2 );
     if( exists( $heap->{ 'users' }->{ uc( $who ) } ) ) {
       if( $heap->{ 'users' }->{ uc( $who ) } eq md5_hex( $old ) ) {
@@ -1571,6 +1575,26 @@ CHECKMEMO: |-
        DumpFile( "memos.yaml", $heap->{ 'memo' } );
   }
 
+COUNTMEMO: |-
+  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 ) } };
+    my $count = scalar @memos;
+    $kernel->post(
+        $src,
+        $replypath,
+        "You have $count memo".($count==1?"":"s")." waiting. To check your memos, please first REGISTER (if you haven't already) and then IDENTIFY.",
+        $dest
+    );
+  }
+
 MEMOLIST: |-
   sub {
     my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
@@ -1997,6 +2021,7 @@ TWITTER: |-
       my $response = $userAgent->request( POST $oaRequest->to_url() );
       if( !$response->is_success() ) {
         print( "TWITTER: Error: ".$response->status_line(), "\n" );
+        print( "TWITTER: URL was '".$oaRequest->to_url()."'\n" );
         if( $response->code == "401" ) {
           $kernel->post( $src, $replypath, "401 from Twitter: This generally means Destult ".
                                            "has been de-authorized to update your Twitter ".
diff --git a/core.pl b/core.pl
index ce550d2..36f4004 100644 (file)
--- a/core.pl
+++ b/core.pl
@@ -40,9 +40,12 @@ sub seen {
        }
        $heap->{ 'seen' }->{ uc( $who ) } = time;
        if( exists( $heap->{ 'memo' } ) &&
-           exists( $heap->{ 'memo' }->{ uc( $who ) } ) && 
-           exists( $heap->{ 'identified' }->{ $src.uc( $who ) } ) ) {
-               $kernel->yield( "cmd", $who, "CHECKMEMO", $src, $who, "send_private", $trusted );
+           exists( $heap->{ 'memo' }->{ uc( $who ) } ) ) {
+           if( exists( $heap->{ 'identified' }->{ $src.uc( $who ) } ) ) {
+                       $kernel->yield( "cmd", $who, "CHECKMEMO", $src, $who, "send_private", $trusted );
+               } else {
+                       $kernel->yield( "cmd", $who, "COUNTMEMO", $src, $who, "send_private", $trusted );
+               }
        }
 }
 
@@ -246,7 +249,6 @@ sub advertise {
 # this should check for hooks stored on the heap. TODO.
 sub on_public {
        my( $kernel, $heap, $who, $what, $src, $dest, $replypath, $trusted ) = @_[ KERNEL, HEAP, ARG0, ARG1, ARG2, ARG3, ARG4, ARG5 ];
-       $kernel->yield( "seen", $who, $what, $src, $dest, $replypath, $trusted );
        my $cmd = ( split( / /, $what, 2 ) )[0];
        # Check for the presence of a command
        if( $cmd =~ /^~.*/ ) {
@@ -266,4 +268,5 @@ sub on_public {
                        $kernel->yield( "cmd", $who, "KARMAUP $1", $src, $dest, $replypath, $trusted );
                }
        }
+       $kernel->yield( "seen", $who, $what, $src, $dest, $replypath, $trusted );
 }
diff --git a/irc.pl b/irc.pl
index 0b8eee4..a57ba85 100644 (file)
--- a/irc.pl
+++ b/irc.pl
@@ -209,8 +209,8 @@ sub on_private {
        $msg =~ s/(\x3)[0-9]{0,2}//g;
        $msg =~ s/\x02//g;
        $cmd = ( split( / /, $msg, 2 ) )[0];
-       $kernel->post( "core", "seen", $who, $msg, $self->{ "ssid" }, $who, "send_private", 1 );
        $kernel->post( "core", "cmd", $who, $msg, $self->{ "ssid" }, $who, "send_private", 1 );
+       $kernel->post( "core", "seen", $who, $msg, $self->{ "ssid" }, $who, "send_private", 1 );
 }
 
 sub send_public {