mirror of
https://github.com/Nick80835/microbot
synced 2025-08-22 10:09:40 +00:00
add size limit to get_image
This commit is contained in:
parent
cfd9aca276
commit
695bd38bda
@ -42,7 +42,7 @@ class ExtendedNewMessage(NewMessage.Event):
|
||||
|
||||
return (default, self) if return_msg else default
|
||||
|
||||
async def get_image(self, event=None, with_reply=True, force_reply=False):
|
||||
async def get_image(self, event: NewMessage.Event = None, with_reply=True, force_reply=False, size_limit: int = 0):
|
||||
event = event or self
|
||||
|
||||
if event and event.media and not force_reply:
|
||||
@ -56,6 +56,9 @@ class ExtendedNewMessage(NewMessage.Event):
|
||||
if event.gif or event.video or event.audio or event.voice:
|
||||
return
|
||||
|
||||
if size_limit and event.file.size > size_limit:
|
||||
return
|
||||
|
||||
return event.media.document
|
||||
|
||||
if with_reply and event.is_reply:
|
||||
|
@ -43,7 +43,7 @@ async def deepfryer(event):
|
||||
except ValueError:
|
||||
frycount = 1
|
||||
|
||||
data = await event.get_image()
|
||||
data = await event.get_image(1024 * 3072)
|
||||
|
||||
if not data:
|
||||
await event.reply("Reply to an image or sticker or caption an image to deep fry it!")
|
||||
|
@ -120,7 +120,7 @@ def flipstickersync(sticker_webp_io):
|
||||
|
||||
@ldr.add("stickimg", help="Converts images to sticker-sized PNG files.")
|
||||
async def createsticker(event):
|
||||
data = await event.get_image()
|
||||
data = await event.get_image(size_limit=1024 * 3072)
|
||||
|
||||
if not data:
|
||||
await event.reply("Reply to or caption an image to make it sticker-sized!")
|
||||
@ -133,7 +133,7 @@ async def createsticker(event):
|
||||
|
||||
@ldr.add("emojiimg", help="Converts images to emoji-sized PNG files.")
|
||||
async def createemoji(event):
|
||||
data = await event.get_image()
|
||||
data = await event.get_image(size_limit=1024 * 3072)
|
||||
|
||||
if not data:
|
||||
await event.reply("Reply to or caption an image to make it emoji-sized!")
|
||||
|
Loading…
x
Reference in New Issue
Block a user