Skip to content

Commit

Permalink
image: Add missing return in except
Browse files Browse the repository at this point in the history
  • Loading branch information
leofah committed Dec 26, 2022
1 parent 61f6d54 commit 4c7e8ee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cyberbot/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,13 @@ async def send_image(self, filename):
width, height = imagesize.get(filename)
except ValueError as e:
self.log.warning(f"Not sending image {filename} due to {e}")
return

p = pathlib.Path(filename)
extension = p.suffix.lower()[1:]
if extension not in ["gif", "png", "jpg", "jpeg"]:
self.log.warning(f"Unsupported image format: {extension}")
return

mime = "image/{}".format(extension.replace("jpeg", "jpg"))
uresp, file_decryption_info = await self.client.upload(
Expand Down Expand Up @@ -287,8 +289,6 @@ async def send_image(self, filename):
c["file"] = file_decryption_info
c["file"]["url"] = uri

self.log.info(c)

await self.client.room_send(
room_id=self.nio_room.room_id,
message_type="m.room.message",
Expand Down

0 comments on commit 4c7e8ee

Please sign in to comment.