-
Notifications
You must be signed in to change notification settings - Fork 79
/
bot.py
50 lines (34 loc) · 1.36 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import logging, asyncio
from os import environ
from pyrogram import Client, filters
from pyrogram.errors import FloodWait
logging.basicConfig(level=logging.ERROR)
SESSION = environ.get("SESSION", "")
User = Client(name="AcceptUser", session_string=SESSION)
@User.on_message(filters.command(["run", "approve"], [".", "/"]))
async def approve(client, message):
Id = message.chat.id
await message.delete(True)
try:
while True: # create loop is better techniq to accept within seconds 💀
try:
await client.approve_all_chat_join_requests(Id)
except FloodWait as t:
asyncio.sleep(t.value)
await client.approve_all_chat_join_requests(Id)
except Exception as e:
logging.error(str(e))
except FloodWait as s:
asyncio.sleep(s.value)
while True:
try:
await client.approve_all_chat_join_requests(Id)
except FloodWait as t:
asyncio.sleep(t.value)
await client.approve_all_chat_join_requests(Id)
except Exception as e:
logging.error(str(e))
msg = await client.send_message(Id, "**Task Completed** ✓ **Approved Pending All Join Request**")
await msg.delete()
logging.info("Bot Started....")
User.run()