Add summary of a cheese

master
Nikola Forró 6 years ago
parent 38f03b98bb
commit fb316537c8

@ -236,4 +236,11 @@ class DiscordClient(discord.Client):
embed = discord.Embed(title=result['name'], url=result['url'],
description=result['description'], color=0xffd700)
embed.set_thumbnail(url=result['image'])
embed.set_image(url=result['image'])
for point in result['summary']:
try:
name, value = point.split(':')
except ValueError:
name, value = 'Base', point
embed.add_field(name=name.strip(), value=value.strip(), inline=True)
await self.send_message(message.channel, embed=embed)

@ -17,10 +17,14 @@ class CheeseCom(object):
if not r.history:
raise CheeseComError('no exact match')
d = pq(r.content)
summary = []
for p in d('ul[class="summary-points"]').find('p').items():
summary.append(p.html(method='text'))
return dict(
url=d('meta[name="twitter:url"]').attr('content'),
name=d('meta[name="twitter:title"]').attr('content'),
description=d('meta[name="twitter:description"]').attr('content'),
image=d('meta[name="twitter:image"]').attr('content'))
image=d('meta[name="twitter:image"]').attr('content'),
summary=summary)
except Exception as e:
raise CheeseComError(str(e))

Loading…
Cancel
Save