Bildirim
T
@TeknoManiablogspot
"er": Geleneksel rütbe sistemi koşulları geçerlidir.
Diğer rütbeleri gör
Gönderileri
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>()]>>Kod
Yığını:
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" continue_script = False if len(sys.argv) == 5: g_index_scrapper = sys.argv[1] g_index_adder = sys.argv[2] mode = sys.argv[3] start_index = sys.argv[4] continue_script = True #Login & Verification Code 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") client(JoinChannelRequest (target_group_scrapper)) time.sleep (2) client(JoinChannelRequest (target_group_adder)) mode = 2 if(mode not in [1,2]): sys.exit("Invalid Mode Selected. Please Try Again.") #Fetching participants from server all_participants = [] print('Fetching Members...') try: all_participants = client.get_participants(target_group_scrapper, aggressive=True) except: print("Unable to fetch participants of", target_group_scrapper) exit() if len(all_participants) == 0: print("No user found in", target_group_scrapper + '.', "Please check the group.") exit() try: target_group_entity_adder = InputPeerChannel(target_group_adder.id, target_group_adder.access_hash) isChannel = True except: target_group_entity_adder = InputPeerChat(target_group_adder.id) isChannel = False n = 0 user_added_count = 0 for i in range(start_index,len(all_participants)): user = all_participants[i] n += 1 if n % 50 == 0: time.sleep(900) try: print("Adding {}".format(user.id)) if mode == 1: try: if user.username != None: user_to_add = client.get_input_entity(user.username) except: continue elif mode == 2: user_to_add = InputPeerUser(user.id, user.access_hash) 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")Kod
Yığını:
Bu arada numaraları aşağıdaki json dosyasında yer alıyor api id ve hash aynı zaten
{ "hesaplar": [ {"phone": "+17602925311"}, {"phone": "+14422190473"}, {"phone": "+17608243569"} ] }Kod
Yığını:
Temel Bilgiler ve İstatistikler
Aktiflik: Şu anda DH'de değil
Son Giriş: 3 yıl önce
Son Mesaj Zamanı: 3 yıl
Mesaj Sayısı: 1
Gerçek Toplam Mesaj Sayısı: 2
İkinci El Bölümü Mesajları: 0
Konularının görüntülenme sayısı: 450 (Bu ay: 3)
Toplam aldığı artı oy sayısı: 0 (Bu hafta: 0)
En çok mesaj yazdığı forum bölümü: Yazılım Geliştirme
Son Giriş: 3 yıl önce
Son Mesaj Zamanı: 3 yıl
Mesaj Sayısı: 1
Gerçek Toplam Mesaj Sayısı: 2
İkinci El Bölümü Mesajları: 0
Konularının görüntülenme sayısı: 450 (Bu ay: 3)
Toplam aldığı artı oy sayısı: 0 (Bu hafta: 0)
En çok mesaj yazdığı forum bölümü: Yazılım Geliştirme
Mesajları
İkinci El Referansları