From 1e9f10d5492882cabd8ba7f3a4ce1fef63749494 Mon Sep 17 00:00:00 2001 From: dece Date: Thu, 2 Dec 2021 11:36:30 +0100 Subject: [PATCH] journee_mondiale: do not crash if text not found --- edmond/plugins/journee_mondiale.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/edmond/plugins/journee_mondiale.py b/edmond/plugins/journee_mondiale.py index 1483d00..ede6a72 100644 --- a/edmond/plugins/journee_mondiale.py +++ b/edmond/plugins/journee_mondiale.py @@ -19,16 +19,21 @@ class JourneeMondialePlugin(Plugin): def on_pubmsg(self, event): if not self.should_handle_command(event.arguments[0], no_content=True): return False + response = http_get(self.config["url"]) if not response: 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(event.target) return True + if jm: self.bot.say(event.target, jm) + else: + self.signal_failure(event.target) return True