diff options
author | David Phillips <david@sighup.nz> | 2018-09-21 14:10:58 +1200 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2018-09-21 14:13:28 +1200 |
commit | cfa90dc368a1ac3441185c94d287829d3985ef6d (patch) | |
tree | 7ded14e51cad7f85e5a60ec7fa8abe41d58319cc /Plugin | |
parent | 62555509a4ced02f05f44e658abf86d7f665d63f (diff) | |
download | idalius-cfa90dc368a1ac3441185c94d287829d3985ef6d.tar.xz |
Validate configuration parameter presence and type
Diffstat (limited to 'Plugin')
-rw-r--r-- | Plugin/Admin.pm | 6 | ||||
-rw-r--r-- | Plugin/Timezone.pm | 3 | ||||
-rw-r--r-- | Plugin/Titillate.pm | 5 | ||||
-rw-r--r-- | Plugin/URL_Title.pm | 6 |
4 files changed, 20 insertions, 0 deletions
diff --git a/Plugin/Admin.pm b/Plugin/Admin.pm index 9313110..ff64d83 100644 --- a/Plugin/Admin.pm +++ b/Plugin/Admin.pm @@ -3,6 +3,8 @@ package Plugin::Admin; use strict; use warnings; +use IdaliusConfig qw/assert_scalar assert_list/; + my $config; sub configure { @@ -11,6 +13,10 @@ sub configure { shift; # run_command $config = shift; + IdaliusConfig::assert_list($config, $self, "admins"); + IdaliusConfig::assert_scalar($config, $self, "must_id"); + IdaliusConfig::assert_scalar($config, $self, "quit_msg"); + $cmdref->("say", sub { $self->say(@_); } ); $cmdref->("action", sub { $self->do_action(@_); } ); diff --git a/Plugin/Timezone.pm b/Plugin/Timezone.pm index c679340..5e649b1 100644 --- a/Plugin/Timezone.pm +++ b/Plugin/Timezone.pm @@ -4,6 +4,7 @@ use strict; use warnings; use DateTime; +use IdaliusConfig qw/assert_dict/; my $config; @@ -13,6 +14,8 @@ sub configure { shift; # run_command $config = shift; + IdaliusConfig::assert_dict($config, $self, "timezone"); + $cmdref->("time", sub { $self->time(@_); } ); return $self; diff --git a/Plugin/Titillate.pm b/Plugin/Titillate.pm index 5ce5eeb..a113fc0 100644 --- a/Plugin/Titillate.pm +++ b/Plugin/Titillate.pm @@ -3,6 +3,8 @@ package Plugin::Titillate; use strict; use warnings; +use IdaliusConfig qw/assert_dict/; + my $config; sub configure { @@ -10,6 +12,9 @@ sub configure { my $cmdref = shift; shift; # run_command $config = shift; + + IdaliusConfig::assert_dict($config, $self, "triggers"); + return $self; } diff --git a/Plugin/URL_Title.pm b/Plugin/URL_Title.pm index 9d20cd6..e93de26 100644 --- a/Plugin/URL_Title.pm +++ b/Plugin/URL_Title.pm @@ -6,6 +6,8 @@ use HTTP::Tiny; use HTML::Parser; use utf8; +use IdaliusConfig qw/assert_scalar/; + my $config; sub configure { @@ -13,6 +15,10 @@ sub configure { my $cmdref = shift; shift; # run_command $config = shift; + + IdaliusConfig::assert_scalar($config, $self, "url_len"); + die "url_len must be positive" if $config->{url_len} <= 0; + return $self; } |