hi everyone,
im new in python. im making a code that add multiple contacts in your telegram account by the username that listed in your csv file.
i have this code. cant seem to work. please help
from telethon.sync import TelegramClient
from telethon import TelegramClient
from telethon.tl.types import InputPeerEmpty, InputPeerChannel, InputPeerUser
from telethon.tl.functions.messages import GetDialogsRequest
from telethon.tl.functions.messages import AddChatUserRequest
from telethon.tl.types import InputPhoneContact
from telethon.tl.functions.contacts import ImportContactsRequest
from telethon import functions, types
import sys
import csv
import traceback
import time
import random
name= #session
api_id = #id
api_hash = #hash
phone = #phone
client = TelegramClient(phone, api_id, api_hash)
client.connect()
if not client.is_user_authorized():
client.send_code_request(phone)
client.sign_in(phone, input('40779'))
user = []
with open(r"members.csv", encoding='UTF-8') as f:
rows = csv.reader(f,delimiter=",",lineterminator="\n")
next(rows, None)
for row in rows:
user = {}
user['username'] = row[0]
user['id'] = int(row[1])
user['access_hash'] = int(row[2])
user['name'] = row[3]
result = client(GetDialogsRequest(
offset_date=None,
offset_id=0,
offset_peer=InputPeerEmpty(),
limit=0,
hash=0))
user_to_add = ['username']
client(functions.contacts.AddContactRequest(id=user_to_add, first_name='User', last_name='', phone='', add_phone_privacy_exception=True))