unknown_question: fix usage of misc_reactions
This commit is contained in:
parent
806ef07e0c
commit
16d0df2a44
|
@ -58,14 +58,17 @@ class MiscReactionsPlugin(Plugin):
|
||||||
|
|
||||||
def on_pubmsg(self, event):
|
def on_pubmsg(self, event):
|
||||||
if proc(self.config["rate"]):
|
if proc(self.config["rate"]):
|
||||||
if self.weights:
|
self.react(event)
|
||||||
method = random.choices(self.reactions, self.weights)[0]
|
|
||||||
else:
|
|
||||||
method = random.choice(self.reactions)
|
|
||||||
method(event)
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def react(self, event):
|
||||||
|
if self.weights:
|
||||||
|
method = random.choices(self.reactions, self.weights)[0]
|
||||||
|
else:
|
||||||
|
method = random.choice(self.reactions)
|
||||||
|
method(event)
|
||||||
|
|
||||||
def react_with_sentence(self, event):
|
def react_with_sentence(self, event):
|
||||||
"""React with a random sentence from config list."""
|
"""React with a random sentence from config list."""
|
||||||
sentences = self.config.get("sentences")
|
sentences = self.config.get("sentences")
|
||||||
|
|
|
@ -26,7 +26,7 @@ class UnknownQuestionPlugin(Plugin):
|
||||||
if message is None:
|
if message is None:
|
||||||
return False
|
return False
|
||||||
if self.misc_plugin and proc(self.config["pass_to_misc_rate"]):
|
if self.misc_plugin and proc(self.config["pass_to_misc_rate"]):
|
||||||
return self.misc_plugin.on_pubmsg(event)
|
self.misc_plugin.react(event)
|
||||||
else:
|
else:
|
||||||
self.bot.say(event.target, "?" * random.randint(1, 3))
|
self.bot.say(event.target, "?" * random.randint(1, 3))
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in a new issue