diff --git a/config.json.example b/config.json.example index 8ce13c8..3c7bbe5 100644 --- a/config.json.example +++ b/config.json.example @@ -110,7 +110,8 @@ }, "random": { "commands": ["choose"], - "separator": "or" + "separator": "or", + "not_enough": "Not enough choices!" }, "sleep": { "commands": ["sleep", "wake up"], diff --git a/edmond/plugins/random.py b/edmond/plugins/random.py index 08eef61..0e52570 100644 --- a/edmond/plugins/random.py +++ b/edmond/plugins/random.py @@ -5,7 +5,7 @@ from edmond.plugin import Plugin class RandomPlugin(Plugin): - REQUIRED_CONFIGS = ["commands", "separator"] + REQUIRED_CONFIGS = ["commands", "separator", "not_enough"] def __init__(self, bot): super().__init__(bot) @@ -16,8 +16,10 @@ class RandomPlugin(Plugin): separator = self.config["separator"] choices = self.command.content.split(f" {separator} ") self.bot.log_d(f"Choices: {choices}") - if len(choices): + if len(choices) > 1: choice = random.choice(choices) if choice: self.bot.say(event.target, choice) + else: + self.bot.say(event.target, self.config["not_enough"]) return True