diff options
-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}; } |