commit - 0b0333461f9db1d7b208b4b016de7f8b2e6cd86d
commit + 7d9238c442e71ea7b906beb7d16e5550568ce326
blob - 486c369f0520dfad07d9650dd622651c16d8c600
blob + 8b11009dd0a28d30842f9ae9f0225f182d36fecc
--- lib/Bot/BasicBot/Pluggable/Module/BotnowDB.pm
+++ lib/Bot/BasicBot/Pluggable/Module/BotnowDB.pm
sub listUsers {
my $self=shift;
+ my $msg=shift;
+ my $reply;
+ if ($msg->{channel} ne 'msg') { # Notify we are replying in PM.
+ $reply = "See Private Message";
+ }
+
my $dbh=$self->connectDB();
my $stmt=qq{SELECT DISTINCT username,email,password from bnc};
my @lines;
next unless (defined $usr->[2]);
push @lines, qq{$usr->[0] : $usr->[1] : $seen->{time}};
}
- my $reply = join ("\n", @lines);
$self->disconnectDB($dbh);
+ my $pm = join ("\n", @lines);
+ $self->say({who=>$msg->{who},channel=>'msg',body=>$pm});
return $reply;
}
sub getUser {
my $self = shift;
+ my $msg=shift;
my $user = shift;
+ my $reply;
+ if ($msg->{channel} ne 'msg') { # Notify we are replying in PM.
+ $reply = "See Private Message";
+ }
my $dbh = $self->connectDB();
my $stmt = qq{select username,email from bnc where username is ?};
my @userDetails = $dbh->selectrow_array($stmt, undef, $user);
- my $reply = $userDetails[0] . ": " . $userDetails[1];
+ my $pm = $userDetails[0] . ": " . $userDetails[1];
my $seen = $self->bot->module('seen')->get("seen_$user");
if (defined $seen) {
- $reply .= "\nLast Seen: " . $seen->{time} . " in " . $seen->{channel} . "\n";
- $reply .= $seen->{what} . ".";
+ $pm .= "\nLast Seen: " . $seen->{time} . " in " . $seen->{channel} . "\n";
+ $pm .= $seen->{what} . ".";
}
$self->disconnectDB($dbh);
+ $self->say({who=>$msg->{who},channel=>'msg',body=>$pm});
return $reply;
}
if($message->{address}) {
my $body = $message->{body};
my $channel = $message->{channel};
- if ($channel eq 'msg') { # was a private message so respond in private message
- $channel = $message->{who};
- }
if($body =~ /^botnow/i) { # Only reply if line begins with botnow
if (not $self->bot->module("Auth")->authed($message->{who})) {
return "Please Authenticate";
my @cmds = split(' ',$body);
shift @cmds; #pop botnow off command list
my %actions = (
- users => sub { return $self->listUsers(@_) },
+ users => sub { return $self->listUsers( @_ ) },
user => sub { return $self->getUser( @_ ) },
);
if (!defined($actions{$cmds[0]})) {
return $self->help();
}
- my $reply = $actions{$cmds[0]}->(@cmds[1,-1]) ;
+ my $reply = $actions{$cmds[0]}->($message, @cmds[1,-1]) ;
return $reply;
}
}