| 35 | |
| 36 | @Drone.on(events.NewMessage(incoming=True, from_users=AUTH, pattern='/batch')) |
| 37 | async def _batch(event): |
| 38 | if not event.is_private: |
| 39 | return |
| 40 | s, r = await force_sub(event.client, fs, event.sender_id, ft) |
| 41 | if s == True: |
| 42 | await event.reply(r) |
| 43 | return |
| 44 | if event.sender_id in batch: |
| 45 | return await event.reply("You've already started one batch, wait for it to complete you dumbfuck owner!") |
| 46 | async with Drone.conversation(event.chat_id) as conv: |
| 47 | if s != True: |
| 48 | await conv.send_message("Send me the message link you want to start saving from, as a reply to this message.", buttons=Button.force_reply()) |
| 49 | try: |
| 50 | link = await conv.get_reply() |
| 51 | try: |
| 52 | _link = get_link(link.text) |
| 53 | except Exception: |
| 54 | await conv.send_message("No link found.") |
| 55 | return conv.cancel() |
| 56 | except Exception as e: |
| 57 | print(e) |
| 58 | await conv.send_message("Cannot wait more longer for your response!") |
| 59 | return conv.cancel() |
| 60 | await conv.send_message("Send me the number of files/range you want to save from the given message, as a reply to this message.", buttons=Button.force_reply()) |
| 61 | try: |
| 62 | _range = await conv.get_reply() |
| 63 | except Exception as e: |
| 64 | print(e) |
| 65 | await conv.send_message("Cannot wait more longer for your response!") |
| 66 | return conv.cancel() |
| 67 | try: |
| 68 | value = int(_range.text) |
| 69 | if value > 100: |
| 70 | await conv.send_message("You can only get upto 100 files in a single batch.") |
| 71 | return conv.cancel() |
| 72 | except ValueError: |
| 73 | await conv.send_message("Range must be an integer!") |
| 74 | return conv.cancel() |
| 75 | batch.append(event.sender_id) |
| 76 | await run_batch(userbot, Bot, event.sender_id, _link, value) |
| 77 | conv.cancel() |
| 78 | batch.clear() |
| 79 | |
| 80 | async def run_batch(userbot, client, sender, link, _range): |
| 81 | for i in range(_range): |