MCPcopy
hub / github.com/vasusen-code/SaveRestrictedContentBot / run_batch

Function run_batch

main/plugins/batch.py:80–112  ·  view source on GitHub ↗
(userbot, client, sender, link, _range)

Source from the content-addressed store, hash-verified

78 batch.clear()
79
80async def run_batch(userbot, client, sender, link, _range):
81 for i in range(_range):
82 timer = 60
83 if i < 25:
84 timer = 5
85 if i < 50 and i > 25:
86 timer = 10
87 if i < 100 and i > 50:
88 timer = 15
89 if not 't.me/c/' in link:
90 if i < 25:
91 timer = 2
92 else:
93 timer = 3
94 try:
95 if not sender in batch:
96 await client.send_message(sender, "Batch completed.")
97 break
98 except Exception as e:
99 print(e)
100 await client.send_message(sender, "Batch completed.")
101 break
102 try:
103 await get_bulk_msg(userbot, client, sender, link, i)
104 except FloodWait as fw:
105 if int(fw.x) > 299:
106 await client.send_message(sender, "Cancelling batch since you have floodwait more than 5 minutes.")
107 break
108 await asyncio.sleep(fw.x + 5)
109 await get_bulk_msg(userbot, client, sender, link, i)
110 protection = await client.send_message(sender, f"Sleeping for `{timer}` seconds to avoid Floodwaits and Protect account!")
111 await asyncio.sleep(timer)
112 await protection.delete()
113

Callers 1

_batchFunction · 0.85

Calls 1

get_bulk_msgFunction · 0.90

Tested by

no test coverage detected