Below is the code I wrote. How can I bypass this error? It’s too difficult.
<code>async def invite_contacts(file_name, group_id):
session_string = import_session_string(file_name)
session_name = file_name.split('\')[-1].replace('_config.py', '')
async with Client(session_name, session_string=session_string) as app:
contacts = await app.get_contacts()
for contact in contacts:
try:
await app.add_chat_members(group_id, [contact.id])
print(f"Added {contact.first_name} ({contact.id}) to the group.")
await asyncio.sleep(30) # 정상 작업 후 30초 휴식
except FloodWait as e:
print(f"FloodWait error, {e.x}seconds wait...")
await asyncio.sleep(e.x) # FloodWait 시간 동안 대기
except PeerIdInvalid:
print("[400 PEER_ID_INVALID] - The peer id being used is invalid or not known yet. Make sure you meet the peer before interacting with it ")
await asyncio.sleep(60) # PeerIdInvalid 오류 시 1분 휴식
except Exception as e:
print(f"알 수 없는 오류 발생: {str(e)}")
await asyncio.sleep(30)
</code>
<code>async def invite_contacts(file_name, group_id):
session_string = import_session_string(file_name)
session_name = file_name.split('\')[-1].replace('_config.py', '')
async with Client(session_name, session_string=session_string) as app:
contacts = await app.get_contacts()
for contact in contacts:
try:
await app.add_chat_members(group_id, [contact.id])
print(f"Added {contact.first_name} ({contact.id}) to the group.")
await asyncio.sleep(30) # 정상 작업 후 30초 휴식
except FloodWait as e:
print(f"FloodWait error, {e.x}seconds wait...")
await asyncio.sleep(e.x) # FloodWait 시간 동안 대기
except PeerIdInvalid:
print("[400 PEER_ID_INVALID] - The peer id being used is invalid or not known yet. Make sure you meet the peer before interacting with it ")
await asyncio.sleep(60) # PeerIdInvalid 오류 시 1분 휴식
except Exception as e:
print(f"알 수 없는 오류 발생: {str(e)}")
await asyncio.sleep(30)
</code>
async def invite_contacts(file_name, group_id):
session_string = import_session_string(file_name)
session_name = file_name.split('\')[-1].replace('_config.py', '')
async with Client(session_name, session_string=session_string) as app:
contacts = await app.get_contacts()
for contact in contacts:
try:
await app.add_chat_members(group_id, [contact.id])
print(f"Added {contact.first_name} ({contact.id}) to the group.")
await asyncio.sleep(30) # 정상 작업 후 30초 휴식
except FloodWait as e:
print(f"FloodWait error, {e.x}seconds wait...")
await asyncio.sleep(e.x) # FloodWait 시간 동안 대기
except PeerIdInvalid:
print("[400 PEER_ID_INVALID] - The peer id being used is invalid or not known yet. Make sure you meet the peer before interacting with it ")
await asyncio.sleep(60) # PeerIdInvalid 오류 시 1분 휴식
except Exception as e:
print(f"알 수 없는 오류 발생: {str(e)}")
await asyncio.sleep(30)
[400 PEER_ID_INVALID] – The peer id being used is invalid or not known yet. Make sure you meet the peer before interacting with it
New contributor
김수호 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.