Handle xkcd title lookup failing
This commit is contained in:
parent
65c1beb010
commit
af8e2d9b53
1 changed files with 5 additions and 3 deletions
8
main.py
8
main.py
|
@ -250,9 +250,11 @@ async def xkcd(args, room, event):
|
|||
title = filter_xkcd_title(line.split(">")[1].split("<")[0])
|
||||
lookup[title] = num
|
||||
user_title = filter_xkcd_title(" ".join(args))
|
||||
title = difflib.get_close_matches(user_title, lookup.keys(), n=1)[0]
|
||||
if title:
|
||||
comic = lookup[title] + "/"
|
||||
title = difflib.get_close_matches(user_title, lookup.keys(), n=1)
|
||||
if len(title) > 0:
|
||||
comic = lookup[title[0]] + "/"
|
||||
else:
|
||||
return await send_text(room.room_id, "Could not find XKCD!")
|
||||
r = requests.get(f"https://xkcd.com/{comic}info.0.json")
|
||||
if settings["debug"]:
|
||||
rj = json.loads(r.text)
|
||||
|
|
Loading…
Reference in a new issue