2014-06-11 15:55:00 +04:00
|
|
|
package II::Config;
|
|
|
|
|
|
|
|
use Config::Tiny;
|
|
|
|
|
|
|
|
sub new {
|
|
|
|
my $class = shift;
|
|
|
|
|
|
|
|
my $c = Config::Tiny->new();
|
|
|
|
$c = Config::Tiny->read('config.ini');
|
|
|
|
|
|
|
|
my $self = { _config => $c, };
|
|
|
|
|
|
|
|
bless $self, $class;
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
2014-08-07 22:21:16 +04:00
|
|
|
# Load configuration
|
2014-06-11 15:55:00 +04:00
|
|
|
sub load {
|
|
|
|
my ($self) = @_;
|
|
|
|
my $config = $self->{_config};
|
|
|
|
|
|
|
|
my $key = $config->{auth}->{key};
|
|
|
|
my $nick = $config->{auth}->{nick};
|
|
|
|
my $host = $config->{node}->{host};
|
|
|
|
my @echoareas = split /,/, $config->{node}->{echoareas};
|
2014-07-30 14:27:48 +04:00
|
|
|
my $name = $config->{node}->{name};
|
2014-06-11 15:55:00 +04:00
|
|
|
|
|
|
|
$c = {
|
|
|
|
nick => $nick,
|
|
|
|
key => $key,
|
|
|
|
host => $host,
|
|
|
|
echoareas => [@echoareas],
|
2014-07-30 14:27:48 +04:00
|
|
|
name => $name,
|
2014-06-11 15:55:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
return $c;
|
|
|
|
}
|
|
|
|
|
2014-08-07 22:21:16 +04:00
|
|
|
# Reload configuration
|
|
|
|
sub reload {
|
|
|
|
my ($self) = @_;
|
|
|
|
|
|
|
|
return II::Config->load();
|
|
|
|
}
|
|
|
|
|
2014-06-11 15:55:00 +04:00
|
|
|
1;
|