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 {
|
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 (defined $stuff and exists $stuff->{nick}) {
|
||||||
if (not $as_text and $self->{registry}->hash->{$section}->{$item}->{type} eq 'array') {
|
if (exists $self->{registry}->hash->{$section} and exists $self->{registry}->hash->{$section}->{"$item.nick.$stuff->{nick}"}) {
|
||||||
return split /\s*,\s*/, $self->{registry}->hash->{$section}->{$item}->{value};
|
$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 {
|
} else {
|
||||||
return $self->{registry}->hash->{$section}->{$item}->{value};
|
return $self->{registry}->hash->{$section}->{$key}->{value};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_array_value {
|
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 (defined $stuff and exists $stuff->{nick}) {
|
||||||
if ($self->{registry}->hash->{$section}->{$item}->{type} eq 'array') {
|
if (exists $self->{registry}->hash->{$section} and exists $self->{registry}->hash->{$section}->{"$item.nick.$stuff->{nick}"}) {
|
||||||
my @array = split /\s*,\s*/, $self->{registry}->hash->{$section}->{$item}->{value};
|
$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];
|
return $array[$index >= $#array ? $#array : $index];
|
||||||
} else {
|
} else {
|
||||||
return $self->{registry}->hash->{$section}->{$item}->{value};
|
return $self->{registry}->hash->{$section}->{$key}->{value};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undef;
|
return undef;
|
||||||
|
Loading…
Reference in New Issue
Block a user