journee_mondiale: do not crash if text not found
This commit is contained in:
parent
6b9430aabb
commit
1e9f10d549
|
@ -19,16 +19,21 @@ class JourneeMondialePlugin(Plugin):
|
||||||
def on_pubmsg(self, event):
|
def on_pubmsg(self, event):
|
||||||
if not self.should_handle_command(event.arguments[0], no_content=True):
|
if not self.should_handle_command(event.arguments[0], no_content=True):
|
||||||
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(event.target)
|
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(event.target)
|
self.signal_failure(event.target)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if jm:
|
if jm:
|
||||||
self.bot.say(event.target, jm)
|
self.bot.say(event.target, jm)
|
||||||
|
else:
|
||||||
|
self.signal_failure(event.target)
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in a new issue