From fb14ff03139a580a903aab4fa9b427b59475f4f5 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Fri, 16 Nov 2018 00:15:30 +1300 Subject: Natural: make chances of speaking configurable --- Plugin/Natural.pm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Plugin/Natural.pm b/Plugin/Natural.pm index 56615e4..2d13070 100644 --- a/Plugin/Natural.pm +++ b/Plugin/Natural.pm @@ -3,26 +3,32 @@ package Plugin::Natural; use strict; use warnings; +my $config; my $root_config; sub configure { my $self = shift; shift; # cmdref shift; # run_command - shift; # module config + $config = shift; $root_config = shift; + IdaliusConfig::assert_scalar($config, $self, "chance_mentioned"); + IdaliusConfig::assert_scalar($config, $self, "chance_otherwise"); + die "chance_mentioned must be from 0 to 100" + if ($config->{chance_mentioned} < 0 || $config->{chance_mentioned} > 100); + die "chance_otherwise must be from 0 to 100" + if ($config->{chance_otherwise} < 0 || $config->{chance_otherwise} > 100); + return $self; } -# FIXME make configurable sub mention_odds { - return int(rand(10)) < 9; + return int(rand(100)) < $config->{chance_mentioned}; } -# FIXME make configurable sub normal_odds { - return int(rand(10)) < 6; + return int(rand(100)) < $config->{chance_otherwise}; } # FIXME factor out with other modules -- cgit v1.1