From bdfa61c97b69f3aafdc2e365bb90c4760a788c85 Mon Sep 17 00:00:00 2001 From: timriker Date: Thu, 21 Nov 2002 21:43:58 +0000 Subject: [PATCH] botmail check git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@672 c11ca15a-4712-0410-83d8-924469b57eb5 --- blootbot/src/Modules/botmail.pl | 29 +++++++++++++---------------- blootbot/src/dbi.pl | 2 +- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/blootbot/src/Modules/botmail.pl b/blootbot/src/Modules/botmail.pl index 95acc7e..aee2419 100644 --- a/blootbot/src/Modules/botmail.pl +++ b/blootbot/src/Modules/botmail.pl @@ -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; } diff --git a/blootbot/src/dbi.pl b/blootbot/src/dbi.pl index e205a4e..29bc5c9 100644 --- a/blootbot/src/dbi.pl +++ b/blootbot/src/dbi.pl @@ -179,7 +179,7 @@ sub dbGetColNiceHash { return; } - %retval = $sth->fetchrow_hashref(); + %retval = %{ $sth->fetchrow_hashref() }; $sth->finish; -- 2.39.5