]> git.donarmstrong.com Git - infobot.git/commitdiff
botmail check
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 21 Nov 2002 21:43:58 +0000 (21:43 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 21 Nov 2002 21:43:58 +0000 (21:43 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@672 c11ca15a-4712-0410-83d8-924469b57eb5

blootbot/src/Modules/botmail.pl
blootbot/src/dbi.pl

index 95acc7e3656817cecf9030402f5bdbc95210c341..aee241990c1036d7c921e6fd2bb3dd155b7726d0 100644 (file)
@@ -19,15 +19,15 @@ sub parse {
        return;
     }
 
-    if ($what =~ /^(add|for)\s+(.*)$/i) {
+    if ($what =~ /^(for|add)\s+(.*)$/i) {
        &add( split(/\s+/, $2, 2) );
 
     } elsif ($what =~ /^check(\s+(.*))?$/i) {
        &check( split(/\s+/, $1, 2) );
 
-    } elsif ($what =~ /^next$/i) {
-       # todo: read specific items? nah, will make this too complex.
-       &read($::who);
+    } elsif ($what =~ /^(read|next)$/i) {
+       # TODO: read specific items? nah, will make this too complex.
+       &next($::who);
 
     }
 }
@@ -53,24 +53,21 @@ sub check {
 }
 
 #####
-# Usage: botmail::read($recipient)
-sub read {
+# Usage: botmail::next($recipient)
+sub next {
     my($recipient) = @_;
 
-    # todo: simplify this select (use a diff function)
-    my $H = &::dbSelectHashref("*", "botmail", "srcwho",
+    my %hash = &::dbGetColNiceHash("botmail", "*",
        "dstwho=".&::dbQuote(lc $recipient)
     );
 
-    my $t = $H->total; # possible?
-
-    if ($t == 0) {
+    if (scalar (keys %hash) <= 1) {
        &::msg($recipient, "You have no botmail.");
     } else {
-       my $ago = &::Time2String(time() - $H->{time});
-       &::msg($recipient, "From $H->{srcwho} ($H->{srcuh}) on $H->{time} [$ago]:");
-       &::msg($recipient, $H->{message});
-       &::dbDel("botmail", "id", $H->{id});
+       my $ago = &::Time2String(time() - $hash{'time'});
+       &::msg($recipient, "From $hash{srcwho} ($hash{srcuh}) on $hash{time} [$ago]:");
+       &::msg($recipient, $hash{'msg'});
+       #&::dbDel("botmail", "id", $hash{id});
     }
 }
 
@@ -92,7 +89,7 @@ sub add {
        "dstwho=".&::dbQuote(lc $recipient)
     );
 
-    if (%hash) {
+    if (scalar (keys %hash) <= 1) {
        &::msg($::who, "$recipient already has a message queued from you");
        return;
     }
index e205a4e8f75d56bad8ec63b69148a0ef6c495114..29bc5c9f8bd3c638bdac0dc1fd43592f3ce1e9a5 100644 (file)
@@ -179,7 +179,7 @@ sub dbGetColNiceHash {
        return;
     }
 
-    %retval = $sth->fetchrow_hashref();
+    %retval = %{ $sth->fetchrow_hashref() };
 
     $sth->finish;