3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-26 05:49:27 +01:00

Add usershow command to show user metadata

This commit is contained in:
Pragmatic Software 2021-07-27 23:46:54 -07:00
parent 62a477b7c4
commit 5dd4566ad4
2 changed files with 26 additions and 2 deletions

View File

@ -18,6 +18,7 @@ sub initialize {
$self->{pbot}->{commands}->register(sub { $self->cmd_logout(@_) }, "logout", 0); $self->{pbot}->{commands}->register(sub { $self->cmd_logout(@_) }, "logout", 0);
$self->{pbot}->{commands}->register(sub { $self->cmd_useradd(@_) }, "useradd", 1); $self->{pbot}->{commands}->register(sub { $self->cmd_useradd(@_) }, "useradd", 1);
$self->{pbot}->{commands}->register(sub { $self->cmd_userdel(@_) }, "userdel", 1); $self->{pbot}->{commands}->register(sub { $self->cmd_userdel(@_) }, "userdel", 1);
$self->{pbot}->{commands}->register(sub { $self->cmd_usershow(@_) }, "usershow", 0);
$self->{pbot}->{commands}->register(sub { $self->cmd_userset(@_) }, "userset", 1); $self->{pbot}->{commands}->register(sub { $self->cmd_userset(@_) }, "userset", 1);
$self->{pbot}->{commands}->register(sub { $self->cmd_userunset(@_) }, "userunset", 1); $self->{pbot}->{commands}->register(sub { $self->cmd_userunset(@_) }, "userunset", 1);
$self->{pbot}->{commands}->register(sub { $self->cmd_users(@_) }, "users", 0); $self->{pbot}->{commands}->register(sub { $self->cmd_users(@_) }, "users", 0);
@ -188,6 +189,30 @@ sub cmd_userdel {
return $self->{pbot}->{users}->remove_user($context->{arguments}); return $self->{pbot}->{users}->remove_user($context->{arguments});
} }
sub cmd_usershow {
my ($self, $context) = @_;
my ($name, $key) = $self->{pbot}->{interpreter}->split_args($context->{arglist}, 2);
if (not defined $name) { return "Usage: usershow <username> [key]"; }
my $channel = $context->{from};
my $target = $self->{pbot}->{users}->{storage}->get_data($name);
if (not $target) {
return "There is no user account $name.";
}
if (lc $key eq 'password') {
return "I don't think so.";
}
my $result = $self->{pbot}->{users}->{storage}->set($name, $key, undef);
$result =~ s/^password: .*;?$/password: <private>;/m;
return $result;
}
sub cmd_userset { sub cmd_userset {
my ($self, $context) = @_; my ($self, $context) = @_;
@ -226,7 +251,6 @@ sub cmd_userset {
} }
my $result = $self->{pbot}->{users}->{storage}->set($name, $key, $value); my $result = $self->{pbot}->{users}->{storage}->set($name, $key, $value);
print "result [$result]\n";
$result =~ s/^password: .*;?$/password: <private>;/m; $result =~ s/^password: .*;?$/password: <private>;/m;
if (defined $key and ($key eq 'channels' or $key eq 'hostmasks') and defined $value) { if (defined $key and ($key eq 'channels' or $key eq 'hostmasks') and defined $value) {

View File

@ -25,7 +25,7 @@ use PBot::Imports;
# These are set by the /misc/update_version script # These are set by the /misc/update_version script
use constant { use constant {
BUILD_NAME => "PBot", BUILD_NAME => "PBot",
BUILD_REVISION => 4322, BUILD_REVISION => 4323,
BUILD_DATE => "2021-07-27", BUILD_DATE => "2021-07-27",
}; };