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.

37 lines
1.1 KiB

import random
from edmond.plugin import Plugin
from edmond.plugins.mood import Mood
from edmond.utils import proc
class ComplimentsPlugin(Plugin):
REQUIRED_CONFIGS = ["sentences", "calm_rate"]
def __init__(self, bot):
super().__init__(bot)
self.priority = -3
self.mood_plugin = None
def on_welcome(self, event):
self.mood_plugin = self.bot.get_plugin("mood")
def on_pubmsg(self, event):
content = self.should_read_message(event.arguments[0])
if content is None:
return False
if content in self.config["sentences"]:
self.react_to_compliment(event.source.nick, event.target)
return True
return False
def react_to_compliment(self, sender, target):
mood = self.get_runtime_value("mood", ns="mood")
if self.mood_plugin is not None:
if mood == Mood.PISSED and proc(self.config["calm_rate"]):
self.mood_plugin.calm_down(target)
compliment = random.choice(self.config["sentences"])
reply = f"{sender} {compliment}"
self.bot.say(target, reply)