Skip to content

Commit

Permalink
fix: svg images from bing image generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanssen0 committed Dec 9, 2023
1 parent 965802a commit 993dd9e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions BotHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,14 @@ async def send_message_async(config: dict, messages: List[Dict],
request_response.response_timestamp = time.time()


async def parse_img(img: str):
res = requests.get(img, timeout=30)
img = Image.open(io.BytesIO(res.content))
async def parse_img(img_source: str):
img = None
try:
res = requests.get(img_source, timeout=30)
img = Image.open(io.BytesIO(res.content))
img.verify()
except Exception:
except Exception as e:
logging.warning("Invalid image from {}: {}, You can ignore this message".format(img_source, str(e)))
return None

if img.format not in ["BMP",
Expand Down

0 comments on commit 993dd9e

Please sign in to comment.