I can't make a mistake in the elevator by telegrams.
-
Hello, everyone. There's no specific knowledge of the python, but I've written a subscription on the telegram for myself, but I can't make a mistake. ♪ On a continuous basis, telegrams are subject to restrictions on subscriptions (which may be 20 minutes). I didn't try, but knowledge is missing. ♪ Maybe someone can help. I need him to either wait for a certain amount of time and get back to work or just miss him.
from telethon import TelegramClient import asyncio
API_ID = 4428245
API_HASH = 'f1296bbf14116c8e2e32767f3ec5bb89'client = TelegramClient('client', api_id=API_ID, api_hash=API_HASH)
async def chats():
with open('channels.txt', 'r') as f:
return f.readlines()async def main():
await client.connect()
channels = await chats()
for i in channels:
await client(JoinChannelRequest(i))
await asyncio.sleep(120)client.start()
client.loop.run_until_complete(main())
-
Look, there's a Python design to make mistakes.
try: <Твой код где будет ловиться ошибка> except: <Что будет когда ошибка произойдёт>
Also, you can recover certain errors by name. For example:
try: 1 / 0 except ZeroDivisionError: # ZeroDivisionError - это название ошибки, в нашем случае деление на ноль. (Его можно узнать как из её происхождения, как это произошло в твоём случае, или просто посмотреть в интернете :) ) print('Произошло деление на ноль')
print('Следующий код...') # Эта строчка выводиться, можешь проверить
Here's the work code:
from telethon import TelegramClient
import asyncioAPI_ID = 4428245
API_HASH = 'f1296bbf14116c8e2e32767f3ec5bb89'client = TelegramClient('client', api_id=API_ID, api_hash=API_HASH)
async def chats():
with open('channels.txt', 'r') as f:
return f.readlines()async def main():
await client.connect()
try:
channels = await chats()
for i in channels:
await client(JoinChannelRequest(i))
await asyncio.sleep(120)
except:
pass # Можешь написать здесь свой код
client.start()
client.loop.run_until_complete(main())