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]) content = " ".join(words[2:-1])
return Command(ident, content) 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 @dataclass
class Question: class Question:

View file

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