Skip to content

Commit f915d90

Browse files
committed
image (most work) and description
So far these don't return an image: - bullsnake - ringneck snake - puff adder
1 parent 49f5251 commit f915d90

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ aiohttp = "<2.3.0,>=2.0.0"
1010
websockets = ">=4.0,<5.0"
1111
"beautifulsoup4" = "*"
1212
lxml = "*"
13+
"html5lib" = "*"
1314

1415
[dev-packages]
1516
"flake8" = "*"

Pipfile.lock

Lines changed: 26 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bot/cogs/logging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ async def on_ready(self):
3030
self.bot.info_url = 'https://snake-facts.weebly.com/'
3131
log.info('Session created!')
3232

33-
with open('./snakes.txt') as f:
33+
with open('./snakes.txt', encoding='utf-8') as f:
3434
self.bot.sneks = f.read().split('\n')
3535
for i, snek in enumerate(self.bot.sneks):
36-
self.bot.sneks[i] = snek.replace('​', '').replace('', '')
36+
self.bot.sneks[i] = snek.replace('\u200b', '').replace('\ufeff', '')
3737

3838
log.info('Snakes loaded.')
3939

bot/cogs/snakes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ def format_info(self, data):
3939
'''Formats the info with the given data'''
4040
em = discord.Embed(
4141
title=f"{data['name']} ({data['scientific-name']})",
42-
description='Nothing yet.',
42+
description=data['description'],
4343
color=discord.Color.green()
4444
)
45-
em.set_thumbnail(url=data['image-url'])
45+
em.set_image(url=data['image-url'])
4646
em.set_footer(text='Bot by SharpBit and Volcyy')
4747

4848
return em
@@ -75,7 +75,8 @@ async def get_snek(self, name: str = None) -> Dict[str, Any]:
7575
info = {
7676
'name': names.h1.string,
7777
'scientific-name': names.h2.string,
78-
'image-url': img
78+
'image-url': img,
79+
'description': soup.find(attrs={'property': {'og:description'}})['content']
7980
}
8081

8182
return info

0 commit comments

Comments
 (0)