From 6aac87f8c8ee19b1063019cce399599d3b1e1b62 Mon Sep 17 00:00:00 2001 From: Al Beano Date: Tue, 19 Jul 2016 15:44:11 +0100 Subject: [PATCH] add option for insult probability --- MarkovBot.pl | 6 ++++-- config.default.yml | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/MarkovBot.pl b/MarkovBot.pl index 8a67915..863c803 100644 --- a/MarkovBot.pl +++ b/MarkovBot.pl @@ -57,12 +57,14 @@ sub said { return unless scalar(@line) > 1; my $start = int rand $#line; my $resp = markov( [$line[$start], $line[$start+1]] ); - $resp = config("insult") unless $resp; + if (rand() * 100 < config("insult_chance") && !$resp) { + $resp = config("insult"); + } $self->say( channel => config("irc_channel"), body => $resp, - ); + ) if $resp; } # Learn diff --git a/config.default.yml b/config.default.yml index e9dbd6f..be889e3 100644 --- a/config.default.yml +++ b/config.default.yml @@ -3,6 +3,8 @@ # command_character: "." insult: "you're a faggot" +insult_chance: 2 # % chance that the bot will use the insult + # can be 0 to disable insults # # Redis Settings