Spaces:
Runtime error
Runtime error
File size: 1,319 Bytes
5126418 |
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 |
import asyncio
from Zaid import call_py, client
from Config import Config
from telethon.tl.functions.channels import LeaveChannelRequest
AUTO_LEAVE_TIME = Config.AUTO_LEAVE_TIME
AUTO_LEAVE = Config.AUTO_LEAVE
async def leave_from_inactive_call():
if AUTO_LEAVE == True:
while not await asyncio.sleep(AUTO_LEAVE_TIME):
all_chat_id = []
async for chat in client.iter_dialogs():
chat_id = chat.id
if chat_id != -1001578320240:
if chat.is_group:
for call in call_py.calls:
call_chat_id = int(getattr(call, "chat_id"))
if call_chat_id in all_chat_id:
pass
else:
all_chat_id.append(call_chat_id)
call_status = getattr(call, "status")
try:
if call_chat_id == chat_id and call_status == "not_playing":
await client(LeaveChannelRequest(chat_id))
elif chat_id not in all_chat_id:
await client(LeaveChannelRequest(chat_id))
except Exception:
pass
if chat_id not in all_chat_id:
try:
await client(LeaveChannelRequest(chat_id))
except Exception:
pass
|