blob: 618b6169405d9a9a553f8d6449032df854e7d6b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/usr/bin/env perl
package sb_config;
use strict;
use warnings;
use Config::Tiny;
sub parse_config
{
my @scalar_configs = ('nick', 'username', 'ircname', 'server', 'port', 'password', 'must_id');
my @list_configs = ('channels', 'ignore', 'admins', 're', 'rep' );
my $file = $_[0];
my %built_config;
my $config = Config::Tiny->read($file);
# FIXME catch undefined/missing config options
foreach my $option (@scalar_configs) {
$built_config{$option} = $config->{_}->{$option};
}
foreach my $option (@list_configs) {
my $vals = $config->{_}->{$option};
$vals =~ s/^\s+|\s+$//g;
@built_config{$option} = [split /\s*,\s*/, $vals];
}
return %built_config;
}
1;
|