You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
606 B

import random
from edmond.plugin import Plugin
class RandomPlugin(Plugin):
REQUIRED_CONFIGS = ["commands", "separator"]
def __init__(self, bot):
super().__init__(bot)
def on_pubmsg(self, event):
if not self.should_handle_command(event.arguments[0]):
return False
separator = self.config["separator"]
choices = self.command.content.split(f" {separator} ")
self.bot.log_d(f"Choices: {choices}")
if len(choices):
choice = random.choice(choices)
if choice:
self.bot.say(event.target, choice)