2 # botmail.pl: Botmail (ala in infobot)
4 # Version: v0.1 (20021122).
6 # NOTE: Motivated by BZFlag.
7 # TODO: full-fledged notes services (optional auth, etc)
17 if (!defined $what or $what =~ /^\s*$/) {
22 if ($what =~ /^add(\s+(.*))?$/i) {
23 &add( split(/\s+/, $1, 2) );
25 } elsif ($what =~ /^next$/i) {
26 # todo: read specific items? nah, will make this too complex.
33 # Usage: botmail::check($who)
37 # todo: simplify this select (use a diff function)
38 my @from = &::dbGet("botmail", "srcwho"
39 "dstwho=".&::dbQuote(lc $w)
42 my $from = join(", ", @from);
45 &::msg($w, "You have no botmail.");
47 &::msg($w, "You have $t messages awaiting, from: $from");
52 # Usage: botmail::read($who)
56 # todo: simplify this select (use a diff function)
57 my $H = &::dbSelectHashref("*", "botmail", "srcwho",
58 "dstwho=".&::dbQuote(lc $w)
61 my $t = $H->total; # possible?
64 &::msg($w, "You have no botmail.");
66 my $ago = &::Time2String(time() - $H->{time});
67 &::msg($w, "From $H->{srcwho} ($H->{srcuh}) on $H->{time} [$ago]:");
68 &::msg($w, $H->{message});
69 &::dbDel("botmail", "id", $H->{id});
74 # Usage: botmail::add($who, $msg)
78 # todo: simplify this select (use a diff function)
79 my $H = &::dbSelectHashref("*", "botmail", "srcwho",
80 "srcwho=".&::dbQuote(lc $::who)." AND ".
81 "dstwho=".&::dbQuote(lc $w)
84 my $t = $H->total; # possible?
86 # only support 1 botmail with unique dstwho/srcwho to have same
87 # functionality as botmail from infobot.
89 &::msg($::who, "$w already has a message queued from you");
93 if (lc $w == $::who) {
94 &::msg($::who, "well... a botmail to oneself is stupid!");
98 &::dbSetRow("botmail", {
101 srcuh => $::nuh{lc $w}, # will this work?
102 -time => "NOW()", # todo: add '-' support.
103 # dbUpdate() supports it.
106 &::msg($::who, "OK, $::who, I'll let $w know.");