Edm0nd/edmond/plugins/mood.py

39 lines
999 B
Python

import random
from enum import Enum
from edmond.plugin import Plugin
class Mood(Enum):
CALM = "calm"
PISSED = "pissed"
class MoodPlugin(Plugin):
REQUIRED_CONFIGS = ["questions", "greetings", "answer"]
def __init__(self, bot):
super().__init__(bot)
def on_welcome(self, event):
mood = random.choice(list(Mood))
self.set_runtime_value("mood", mood)
def on_join(self, event):
if event.source.nick != self.bot.nick:
return
mood = self.get_runtime_value("mood")
greetings = self.config["greetings"].get(mood.value)
if greetings:
self.bot.say(event.target, random.choice(greetings))
def on_pubmsg(self, event):
if not self.should_answer_question(event.arguments[0]):
return False
mood = self.get_runtime_value("mood")
answer = self.config["answer"].get(mood.value)
if answer:
self.bot.say(event.target, answer)
return True