aboutsummaryrefslogtreecommitdiff
path: root/Plugin
diff options
context:
space:
mode:
authorDavid Phillips <david@yeah.nah.nz>2018-11-16 00:15:30 +1300
committerDavid Phillips <david@yeah.nah.nz>2018-11-16 00:19:18 +1300
commitfb14ff03139a580a903aab4fa9b427b59475f4f5 (patch)
treea712155dec6bc0d06d3b859fd5c6dc107ef81c06 /Plugin
parent58ac2ddad36ed6a1c465549116300fa520a38c56 (diff)
downloadidalius-fb14ff03139a580a903aab4fa9b427b59475f4f5.tar.xz
Natural: make chances of speaking configurable
Diffstat (limited to 'Plugin')
-rw-r--r--Plugin/Natural.pm16
1 files 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