Edm0nd/edmond/plugins/random.py

24 lines
626 B
Python
Raw Normal View History

2020-10-09 18:57:26 +02:00
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:
2020-10-09 23:37:35 +02:00
self.bot.say(event.target, choice)
2020-11-06 15:17:29 +01:00
return True