plugin: add forgotten signal_failure method

This commit is contained in:
dece 2020-10-09 22:34:47 +02:00
parent 5ed9d2f3ce
commit 74343e2a24
2 changed files with 6 additions and 2 deletions

View file

@ -93,6 +93,10 @@ class Plugin:
content = " ".join(words[2:-1])
return Command(ident, content)
def signal_failure(self, target):
"""Signal a plugin failure to target."""
self.bot.say(target, self.bot.config["error_message"])
@dataclass
class Question:

View file

@ -21,13 +21,13 @@ class JourneeMondialePlugin(Plugin):
return False
response = http_get(self.config["url"])
if not response:
self.signal_failure()
self.signal_failure(event.target)
return True
soup = BeautifulSoup(response, "html.parser")
try:
jm = soup.find("div", id="journeesDuJour").find("h2").string
except (ValueError, KeyError):
self.signal_failure()
self.signal_failure(event.target)
return True
self.bot.say(event.target, jm)
return True