mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-19 10:03:40 +01:00
Allow OCRing multiple images
This commit is contained in:
parent
7524e5ecfe
commit
03325a266f
1 changed files with 17 additions and 15 deletions
|
@ -595,24 +595,26 @@ class OtherCog(commands.Cog):
|
||||||
@commands.message_command(name="Run OCR")
|
@commands.message_command(name="Run OCR")
|
||||||
async def message_ocr(self, ctx: discord.ApplicationContext, message: discord.Message):
|
async def message_ocr(self, ctx: discord.ApplicationContext, message: discord.Message):
|
||||||
await ctx.defer()
|
await ctx.defer()
|
||||||
attachment: discord.Attachment | None
|
|
||||||
|
embeds = []
|
||||||
for attachment in message.attachments:
|
for attachment in message.attachments:
|
||||||
if attachment.content_type.startswith("image/"):
|
if attachment.content_type.startswith("image/"):
|
||||||
break
|
timings, text = await self._ocr_core(attachment)
|
||||||
else:
|
embed = discord.Embed(
|
||||||
return await ctx.respond(":x: No images found in message.", delete_after=30)
|
title="OCR for " + attachment.filename,
|
||||||
|
description=text,
|
||||||
|
colour=discord.Colour.blurple(),
|
||||||
|
url=message.jump_url
|
||||||
|
)
|
||||||
|
embed.set_image(url=attachment.url)
|
||||||
|
embeds.append(embed)
|
||||||
|
if len(embeds) == 25:
|
||||||
|
break
|
||||||
|
|
||||||
timings, text = await self._ocr_core(attachment)
|
if not embeds:
|
||||||
embed = discord.Embed(
|
return await ctx.respond(":x: No images found in message.", delete_after=30)
|
||||||
title="OCR for " + attachment.filename,
|
else:
|
||||||
description=text,
|
return await ctx.respond(embeds)
|
||||||
colour=discord.Colour.blurple(),
|
|
||||||
url=message.jump_url
|
|
||||||
)
|
|
||||||
embed.set_image(url=attachment.url)
|
|
||||||
await ctx.respond(
|
|
||||||
embed=embed
|
|
||||||
)
|
|
||||||
|
|
||||||
@commands.message_command(name="Convert Image to GIF")
|
@commands.message_command(name="Convert Image to GIF")
|
||||||
async def convert_image_to_gif(self, ctx: discord.ApplicationContext, message: discord.Message):
|
async def convert_image_to_gif(self, ctx: discord.ApplicationContext, message: discord.Message):
|
||||||
|
|
Loading…
Reference in a new issue