Add reply_chance to markov chains and markov commands

Every time a user sends a message, there is now a chance that markov
will reply with a random message based on what they said. !markov chance
allows lookups and setting of the chance that a user may receive a
message.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-07-17 21:39:39 -07:00
parent e375f1604a
commit 109cd67b37
3 changed files with 55 additions and 9 deletions

View File

@@ -3,7 +3,7 @@ defmodule Omnibot.Contrib.Markov.Chain do
require Logger
@enforce_keys [:order]
defstruct order: 2, chain: %{}
defstruct order: 2, chain: %{}, reply_chance: 0.01
def train(chain, line) when is_binary(line) do
train(chain, line |> String.split(~r/\s+/))