mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-20 02:49:49 +01:00
Registry: can now set nick-specific registry values; e.g. default_ban_timeout.nick.pragma-
This commit is contained in:
parent
f4473832ee
commit
8b60162a10
@ -145,27 +145,41 @@ sub unset {
|
||||
}
|
||||
|
||||
sub get_value {
|
||||
my ($self, $section, $item, $as_text) = @_;
|
||||
my ($self, $section, $item, $as_text, $stuff) = @_;
|
||||
my $key = $item;
|
||||
|
||||
if (exists $self->{registry}->hash->{$section} and exists $self->{registry}->hash->{$section}->{$item}) {
|
||||
if (not $as_text and $self->{registry}->hash->{$section}->{$item}->{type} eq 'array') {
|
||||
return split /\s*,\s*/, $self->{registry}->hash->{$section}->{$item}->{value};
|
||||
if (defined $stuff and exists $stuff->{nick}) {
|
||||
if (exists $self->{registry}->hash->{$section} and exists $self->{registry}->hash->{$section}->{"$item.nick.$stuff->{nick}"}) {
|
||||
$key = "$item.nick.$stuff->{nick}";
|
||||
}
|
||||
}
|
||||
|
||||
if (exists $self->{registry}->hash->{$section} and exists $self->{registry}->hash->{$section}->{$key}) {
|
||||
if (not $as_text and $self->{registry}->hash->{$section}->{$key}->{type} eq 'array') {
|
||||
return split /\s*,\s*/, $self->{registry}->hash->{$section}->{$key}->{value};
|
||||
} else {
|
||||
return $self->{registry}->hash->{$section}->{$item}->{value};
|
||||
return $self->{registry}->hash->{$section}->{$key}->{value};
|
||||
}
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub get_array_value {
|
||||
my ($self, $section, $item, $index) = @_;
|
||||
my ($self, $section, $item, $index, $stuff) = @_;
|
||||
my $key = $item;
|
||||
|
||||
if (exists $self->{registry}->hash->{$section} and exists $self->{registry}->hash->{$section}->{$item}) {
|
||||
if ($self->{registry}->hash->{$section}->{$item}->{type} eq 'array') {
|
||||
my @array = split /\s*,\s*/, $self->{registry}->hash->{$section}->{$item}->{value};
|
||||
if (defined $stuff and exists $stuff->{nick}) {
|
||||
if (exists $self->{registry}->hash->{$section} and exists $self->{registry}->hash->{$section}->{"$item.nick.$stuff->{nick}"}) {
|
||||
$key = "$item.nick.$stuff->{nick}";
|
||||
}
|
||||
}
|
||||
|
||||
if (exists $self->{registry}->hash->{$section} and exists $self->{registry}->hash->{$section}->{$key}) {
|
||||
if ($self->{registry}->hash->{$section}->{$key}->{type} eq 'array') {
|
||||
my @array = split /\s*,\s*/, $self->{registry}->hash->{$section}->{$key}->{value};
|
||||
return $array[$index >= $#array ? $#array : $index];
|
||||
} else {
|
||||
return $self->{registry}->hash->{$section}->{$item}->{value};
|
||||
return $self->{registry}->hash->{$section}->{$key}->{value};
|
||||
}
|
||||
}
|
||||
return undef;
|
||||
|
Loading…
Reference in New Issue
Block a user