idk what i did here but it works

This commit is contained in:
blank X 2020-10-17 13:39:42 +07:00
parent 31d8640281
commit 89baa867cc
1 changed files with 20 additions and 8 deletions

View File

@ -11,8 +11,10 @@ async def delete(client, message):
if not getattr(reply, 'empty', True): if not getattr(reply, 'empty', True):
messages.add(reply.message_id) messages.add(reply.message_id)
else: else:
async for i in client.search_messages(message.chat.id, offset=1, limit=1, from_user='me'): async for i in client.iter_history(message.chat.id, offset=1):
if i.outgoing:
messages.add(i.message_id) messages.add(i.message_id)
break
await client.delete_messages(message.chat.id, messages) await client.delete_messages(message.chat.id, messages)
@Client.on_message(~filters.sticker & ~filters.via_bot & ~filters.edited & filters.me & filters.command(['p', 'purge', 'sp', 'selfpurge'], prefixes=config['config']['prefixes'])) @Client.on_message(~filters.sticker & ~filters.via_bot & ~filters.edited & filters.me & filters.command(['p', 'purge', 'sp', 'selfpurge'], prefixes=config['config']['prefixes']))
@ -20,15 +22,25 @@ async def delete(client, message):
@public_log_errors @public_log_errors
async def purge(client, message): async def purge(client, message):
command = message.command command = message.command
selfpurge = 'me' if 's' in message.command.pop(0) else None selfpurge = 's' in command.pop(0)
command = ' '.join(command) command = ' '.join(command)
ids = set((message.message_id,)) ids = set((message.message_id,))
reply = message.reply_to_message reply = message.reply_to_message
if command.isnumeric(): if command.isnumeric():
async for i in client.search_messages(message.chat.id, limit=int(command), offset=1, from_user=selfpurge): command = int(command)
if selfpurge:
async for i in client.iter_history(message.chat.id, offset=1):
if not (selfpurge and not i.outgoing):
ids.add(i.message_id)
command -= 1
if command <= 0:
break
else:
async for i in client.iter_history(message.chat.id, offset=1, limit=command):
ids.add(i.message_id) ids.add(i.message_id)
elif not getattr(reply, 'empty', True): elif not getattr(reply, 'empty', True):
async for i in client.search_messages(message.chat.id, offset=1, from_user=selfpurge): async for i in client.iter_history(message.chat.id, offset=1):
if not (selfpurge and not i.outgoing):
ids.add(i.message_id) ids.add(i.message_id)
if reply.message_id >= i.message_id: if reply.message_id >= i.message_id:
break break
@ -53,7 +65,7 @@ async def yeetpurge(client, message):
thing = [og_reply, reply.message_id] thing = [og_reply, reply.message_id]
thing.sort() thing.sort()
thing0, thing1 = thing thing0, thing1 = thing
async for i in client.iter_history(message.chat.id, offset_id=thing1): async for i in client.iter_history(message.chat.id, offset_id=thing1 + 1):
if not ('s' in message.command[0] and not i.outgoing): if not ('s' in message.command[0] and not i.outgoing):
messages.add(i.message_id) messages.add(i.message_id)
if thing0 >= i.message_id: if thing0 >= i.message_id: