diff options
author | David Phillips <david@sighup.nz> | 2017-03-26 20:47:50 +1300 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2017-03-26 20:50:09 +1300 |
commit | 8d54e0108503016811b4f4626bb476410b206d21 (patch) | |
tree | 6c87e5a87fc613a84a7c18c2a950a94e58b9a40a | |
parent | 026c631ae87e03ee6395f45fe4c47165fa1e6d75 (diff) | |
download | idalius-8d54e0108503016811b4f4626bb476410b206d21.tar.xz |
Enforce setting of scalar configs
-rwxr-xr-x | idalius.pl | 8 | ||||
-rw-r--r-- | sb_config.pm | 5 |
2 files changed, 10 insertions, 3 deletions
@@ -25,9 +25,11 @@ my $irc = POE::Component::IRC->spawn( ) or die "Failed to create new PoCo-IRC: $!"; # Plugins -$irc->plugin_add('NickServID', POE::Component::IRC::Plugin::NickServID->new( - Password => $config{password} -)); +$config{password} and $irc->plugin_add( + 'NickServID', + POE::Component::IRC::Plugin::NickServID->new( + Password => $config{password} + )); POE::Session->create( package_states => [ diff --git a/sb_config.pm b/sb_config.pm index ee816b0..39e92aa 100644 --- a/sb_config.pm +++ b/sb_config.pm @@ -10,12 +10,17 @@ sub parse_config { my @scalar_configs = ('nick', 'username', 'ircname', 'server', 'port', 'usessl', 'password', 'must_id', 'quit_msg', 'user', 'group'); my @list_configs = ('channels', 'ignore', 'admins'); + 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}; } |