Merge remote-tracking branch 'origin/lovecalculator_develop' into lovecalculator_develop

# Conflicts:
#	lovecalculator/lovecalculator.py
pull/129/head
bobloy 4 years ago
commit 88a2049a53

@ -34,20 +34,21 @@ class LoveCalculator(Cog):
) )
async with aiohttp.ClientSession(headers={"Connection": "keep-alive"}) as session: async with aiohttp.ClientSession(headers={"Connection": "keep-alive"}) as session:
async with session.get(url) as response: async with session.get(url) as response:
log.debug(f"{response=}")
assert response.status == 200 assert response.status == 200
soup_object = BeautifulSoup(await response.text(), "html.parser") resp = await response.text()
try: log.debug(f"{resp=}")
description = ( soup_object = BeautifulSoup(resp, "html.parser")
soup_object.find("div", class_="result__score").get_text().strip() try:
) description = (
except: soup_object.find("div", class_="result__score").get_text().strip()
description = "Dr. Love is busy right now" )
except:
description = "Dr. Love is busy right now"
result_image = soup_object.find("img", class_="result__image").get("src") result_image = soup_object.find("img", class_="result__image").get("src")
result_text = soup_object.find("div", class_="result-text").get_text() result_text = soup_object.find("div", class_="result-text").get_text()
result_text = " ".join(result_text.split()) result_text = " ".join(result_text.split())
try: try:
z = description[:2] z = description[:2]
@ -60,8 +61,6 @@ class LoveCalculator(Cog):
except: except:
title = "Dr. Love has left a note for you." title = "Dr. Love has left a note for you."
em = discord.Embed(title=title, description=result_text, color=discord.Color.red()) em = discord.Embed(title=title, description=result_text, color=discord.Color.red(), url=f"https://www.lovecalculator.com/{result_image}")
if result_image:
em.set_image(url=f"https://www.lovecalculator.com/{result_image}")
await ctx.send(embed=em) await ctx.send(embed=em)

Loading…
Cancel
Save