Skip to content
This repository has been archived by the owner on Dec 30, 2024. It is now read-only.

Commit

Permalink
feat: exclude non-generated images url
Browse files Browse the repository at this point in the history
  • Loading branch information
FuseFairy committed Jun 10, 2024
1 parent 5adc1f2 commit 51ffcb5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/image/image_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,21 @@ async def create_image_bing(chatbot, interaction: discord.Interaction, prompt: s

async_gen = ImageGenAsync(auth_cookie=auth_cookie, quiet=True, proxy=os.getenv("PROXY"))
images = await async_gen.get_images(prompt=prompt, timeout=int(os.getenv("IMAGE_TIMEOUT")), max_generate_time_sec=int(os.getenv("IMAGE_MAX_CREATE_SEC")))
images = [file for file in images if not file.endswith('.svg')]
images = [file for file in images if not (file.endswith('.svg') or file.endswith('.js'))]
new_image = await concatenate_images(images)
image_data = BytesIO()
new_image.save(image_data, format='PNG')
image_data.seek(0)

await interaction.followup.send(prompts, file=discord.File(fp=image_data, filename='new_image.png'), view=ButtonView(interaction, prompt, chatbot, images))
except asyncio.TimeoutError:
await interaction.followup.send("> **Error:Request timed out.**")
await interaction.followup.send("> **ERROR:Request timed out.**")
logger.error("Error while create image:Request timed out.")
except TypeError:
await interaction.followup.send("> **Error:No images returned.**")
await interaction.followup.send("> **ERROR:No images returned.**")
logger.error("Error while create image:No images returned.")
except Exception as e:
await interaction.followup.send(f"> **Error{e}**")
await interaction.followup.send(f"> **ERROR{e}**")
logger.error(f"Error while create image:{e}")

async def concatenate_images(image_urls):
Expand Down

0 comments on commit 51ffcb5

Please sign in to comment.