Skip to content

Commit

Permalink
pmpermit: getapprove: send as file if output too long
Browse files Browse the repository at this point in the history
Signed-off-by: Bian <[email protected]>
  • Loading branch information
BianSepang committed Dec 23, 2021
1 parent 37fd058 commit 61d1901
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions userbot/modules/pmpermit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#
""" Userbot module for keeping control who PM you. """

from io import BytesIO

from sqlalchemy.exc import IntegrityError
from telethon.tl.functions.contacts import BlockRequest, UnblockRequest
from telethon.tl.functions.messages import ReportSpamRequest
Expand Down Expand Up @@ -435,6 +437,13 @@ async def get_approve(event):
)
msg += f"• {user_msg} | `{user.id}`\n"

if len(msg) >= 4096:
with BytesIO(str.encode(msg)) as file:
file.name = "approved_users.txt"
await event.edit("`List too long, sending as file:`")
await event.reply(file=file)
return

await event.edit(msg)


Expand Down

0 comments on commit 61d1901

Please sign in to comment.