2020-11-02 18:34:55 +01:00
|
|
|
import hashlib
|
|
|
|
import random
|
|
|
|
import time
|
|
|
|
|
|
|
|
from edmond.plugin import Plugin
|
|
|
|
|
|
|
|
|
|
|
|
class OpinionPlugin(Plugin):
|
|
|
|
|
|
|
|
REQUIRED_CONFIGS = [
|
2022-08-09 23:47:28 +02:00
|
|
|
"questions",
|
|
|
|
"thinking",
|
|
|
|
"thinking_time",
|
|
|
|
"positive",
|
|
|
|
"negative",
|
2020-11-02 18:34:55 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
def __init__(self, bot):
|
|
|
|
super().__init__(bot)
|
|
|
|
|
|
|
|
def on_pubmsg(self, event):
|
|
|
|
if not self.should_answer_question(event.arguments[0]):
|
|
|
|
return False
|
|
|
|
|
|
|
|
self.bot.say(event.target, self.config["thinking"])
|
|
|
|
time.sleep(self.config["thinking_time"])
|
|
|
|
|
|
|
|
content = self.question.content
|
|
|
|
positive = not bool(hashlib.md5(content.encode()).digest()[0] % 2)
|
|
|
|
reply_list = self.config["positive" if positive else "negative"]
|
|
|
|
reply = f"{content}... {random.choice(reply_list)}"
|
|
|
|
self.bot.say(event.target, reply)
|
2020-11-06 15:17:29 +01:00
|
|
|
return True
|