plugins: fix on_pubmsg return values

This commit is contained in:
dece 2020-11-06 15:17:29 +01:00
parent 7f75b15207
commit 937c5ad203
5 changed files with 13 additions and 9 deletions

View file

@ -31,22 +31,21 @@ class MusicPlugin(Plugin):
if self.command.ident == self.config["commands"][0]:
decade = random.choice(self.DECADES)
return self.tell_album_from_decade(event.target, decade)
self.tell_album_from_decade(event.target, decade)
elif self.command.ident == self.config["commands"][1]:
decade = self.parse_decade(self.command.content)
if decade is None:
self.signal_failure(event.target)
return False
return self.tell_album_from_decade(event.target, decade)
return False
else:
self.tell_album_from_decade(event.target, decade)
return True
def tell_album_from_decade(self, target, decade):
album = self.get_random_album(decade)
if not album:
self.signal_failure(target)
return False
return
self.bot.say(target, album)
return True
def get_random_album(self, decade):
"""Return an album as str from this decade from Scaruffi website."""

View file

@ -26,3 +26,4 @@ class OpinionPlugin(Plugin):
reply_list = self.config["positive" if positive else "negative"]
reply = f"{content}... {random.choice(reply_list)}"
self.bot.say(event.target, reply)
return True

View file

@ -20,3 +20,4 @@ class RandomPlugin(Plugin):
choice = random.choice(choices)
if choice:
self.bot.say(event.target, choice)
return True

View file

@ -22,10 +22,12 @@ class TranslatePlugin(Plugin):
text = self.command.content
if not text:
return False
self.signal_failure(event.target)
return True
words = text.split()
if len(words) == 0:
return False
self.signal_failure(event.target)
return True
from_lang, to_lang, text = self.parse_words(words)
self.bot.log_d(f"Translating '{text}' from {from_lang} to {to_lang}.")

View file

@ -36,7 +36,8 @@ class UnknownCommandPlugin(Plugin):
return False
words = message.split()
if len(words) == 0 or words[-1] != self.config["command_suffix"]:
return False
self.signal_failure(event.target)
return True
query = " ".join(words[:-1])
self.process_query(query, event.target)