aboutsummaryrefslogtreecommitdiff
path: root/config_file.pm
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2018-09-16 20:35:03 +1200
committerDavid Phillips <david@sighup.nz>2018-09-16 20:35:03 +1200
commit5f684115bdef65f387e83ad2dfb70fe6d17ed17e (patch)
tree6730b0707cc8a0d21ec77ae3f26902aa6e640bd1 /config_file.pm
parent09f1ca71c2652a029577d23b615c1ebfb8d27f71 (diff)
downloadidalius-5f684115bdef65f387e83ad2dfb70fe6d17ed17e.tar.xz
Rename config_file.pm to IdaliusConfig.pm
Diffstat (limited to 'config_file.pm')
-rw-r--r--config_file.pm83
1 files changed, 0 insertions, 83 deletions
diff --git a/config_file.pm b/config_file.pm
deleted file mode 100644
index 2b7b366..0000000
--- a/config_file.pm
+++ /dev/null
@@ -1,83 +0,0 @@
-package config_file;
-
-use strict;
-use warnings;
-use Config::Tiny;
-
-sub parse_config
-{
- my @scalar_configs = (
- 'nick',
- 'username',
- 'ircname',
- 'server',
- 'port',
- 'usessl',
- 'sslcert',
- 'sslkey',
- 'password',
- 'must_id',
- 'quit_msg',
- 'user',
- 'group',
- 'url_len',
- 'prefix_nick',
- 'prefix');
- my @list_configs = (
- 'channels',
- 'ignore',
- 'admins',
- 'plugins');
- my @optional_configs = (
- 'password');
- my $file = $_[0];
- my %built_config;
- my $config = Config::Tiny->read($file);
-
- # FIXME catch undefined/missing config options
- foreach my $option (@scalar_configs) {
- my $value = $config->{_}->{$option};
- if (! defined $value && ! grep {$_ eq $option} @optional_configs) {
- die "Option \"$option\" must be set in $file\n";
- }
- $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];
- }
-
- # special case: triggers hash
- my %triggers;
- foreach (split ',', $config->{_}->{triggers}) {
- my ($match, $response) = split /=>/;
- # strip outer quotes
- $match =~ s/^[^']*'|'[^']*$//g;
- $response =~ s/^[^']*'|'[^']*$//g;
- $triggers{$match} = $response;
- }
-
- # special case: timezones hash
- my %timezone;
- foreach (split ',', $config->{_}->{timezone}) {
- my ($who, $tz) = split /=>/;
- # strip outer quotes
- $who =~ s/^[^']*'|'[^']*$//g;
- $tz =~ s/^[^']*'|'[^']*$//g;
- $timezone{$who} = $tz;
- }
-
- $built_config{uid} = getpwnam($built_config{user})
- or die "Cannot get uid of $built_config{user}: $!\n";
- $built_config{gid} = getgrnam($built_config{group})
- or die "Cannot get gid of $built_config{group}: $!\n";
-
-
- $built_config{triggers} = \%triggers;
- $built_config{timezone} = \%timezone;
-
- return %built_config;
-}
-1;