Selamlar arkadaşlar telegram grubuma üye eklemek için bir script kullanmaya başladım ilk gün sorunsuz scripti çalıştırabildim ancak sonraki günlerde aşağıdaki hatayı almaya başladım.
Task was destroyed but it is pending! task: <Task pending name='Task-48' coro=<Connection._send_loop() running at /Users/macbook/PycharmProjects/lcksdks/venv/lib/python3.8/site-packages/telethon/network/connection/connection.py:167> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7ffeb6ed8580>()]>> Task was destroyed but it is pending! task: <Task pending name='Task-49' coro=<Connection._recv_loop() running at /Users/macbook/PycharmProjects/lcksdks/venv/lib/python3.8/site-packages/telethon/network/connection/connection.py:185> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7ffeb6ed6c70>()]>> Task was destroyed but it is pending! task: <Task pending name='Task-50' coro=<MTProtoSender._send_loop() running at /Users/macbook/PycharmProjects/lcksdks/venv/lib/python3.8/site-packages/telethon/network/mtprotosender.py:442> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7ffeb6ed6c40>()]>> Task was destroyed but it is pending! task: <Task pending name='Task-51' coro=<MTProtoSender._recv_loop() running at /Users/macbook/PycharmProjects/lcksdks/venv/lib/python3.8/site-packages/telethon/network/mtprotosender.py:485> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7ffeb6ed6d30>()]>>
Acaba bu hatayı nasıl düzeltirim kaynak kod aşağıdaki gibi:
import sys import csv import traceback import time import random import json
from telethon.sync import TelegramClient #Client Module to Login
from telethon.tl.functions.channels import JoinChannelRequest,InviteToChannelRequest from telethon.tl.functions.messages import GetDialogsRequest from telethon.tl.types import InputPeerEmpty, InputPeerChannel, InputPeerUser, InputPeerChat
from telethon.errors.rpcerrorlist import PeerFloodError, UserPrivacyRestrictedError, UserAlreadyParticipantError
from telethon.tl.functions.channels import InviteToChannelRequest from telethon.tl.functions.messages import AddChatUserRequest
hesap_listesi=[]
with open("credentials.json") as hesaplar: data = json.load(hesaplar) for h in data["hesaplar"]: hesap_listesi.append(h)
for i in hesap_listesi : phone = i["phone"] api_id = api_hash = "" try: client = TelegramClient(phone, api_id, api_hash) client.connect() except: print("Could not create Telegram Client, Please check your Credentials in credentials.json file") exit()
if not client.is_user_authorized () : client.send_code_request (i["phone"]) client.sign_in (phone, input ('Enter veryfication code: '))
print(hesap_listesi) start_index = 1100 for i in hesap_listesi: phone = i["phone"] api_id = 1807731 api_hash = "142d6bcef51361b90dcd5aeb8d8dc247"
try: client = TelegramClient(phone, api_id, api_hash) client.connect() except: print("Could not create Telegram Client, Please check your Credentials in credentials.json file") exit()
for i in hesap_listesi: if not client.is_user_authorized(): client.send_code_request(i["phone"]) client.sign_in(phone, input('Enter veryfication code: '))
#Chat parameters chats = [] last_date = None chunk_size = 200 # No of latest chats to load groups = []
try: result = client(GetDialogsRequest( offset_date=last_date, offset_id=0, offset_peer=InputPeerEmpty(), limit=chunk_size, hash=0 )) chats.extend(result.chats) except: print("Unable to gather chats from server. Please Check Chat parameters.") exit()
for chat in chats : try : if chat.megagroup == True : groups.append (chat) except : continue
if len(groups) == 0: print("No Groups or Channels found.") exit()
print('Available Groups and Channels:') i=1 for g in groups: print(str(i) + '- ' + g.title) i+=1
#User Inputs if not continue_script: target_group_scrapper = client.get_entity("https://t.me/indirimalarmi") target_group_adder = client.get_entity("https://t.me/apkmeydanii")
if isChannel: client(InviteToChannelRequest(target_group_entity_adder, [user_to_add])) else: client(InviteToChannelRequest(target_group_adder.id, user_to_add,fwd_limit=50))
user_added_count += 1 wait_time = random.randrange(60, 90) print("Waiting for",wait_time, "Seconds...") time.sleep(wait_time) except PeerFloodError: print("Getting Flood Error from telegram. Script is stopping now. Please try again after some time.") print("Run the following command after few hours to contiune where you left off:") print("python3 scrapper_and_adder.py", i) start_index = i continue_script = False break except UserPrivacyRestrictedError: print("The user's privacy settings do not allow you to do this. Skipping.") except UserAlreadyParticipantError: continue except: traceback.print_exc() print("Unexpected Error") continue
print("Added:", user_added_count, "users to the group")
Bu arada numaraları aşağıdaki json dosyasında yer alıyor api id ve hash aynı zaten
Acaba bu hatayı nasıl düzeltirim kaynak kod aşağıdaki gibi:
Bu arada numaraları aşağıdaki json dosyasında yer alıyor api id ve hash aynı zaten