Created
December 28, 2020 15:55
-
-
Save SmartManoj/0f5caf0556645beaa7bdadd6ad7ca75f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import random | |
from telethon import TelegramClient, events, sync | |
from telethon.tl.types import InputPhoneContact | |
from telethon import functions, types | |
api_id = 210829 | |
api_hash = '..' | |
client = TelegramClient('SmartManoj2', api_id, api_hash) | |
with open('contacts.csv', 'r') as file: | |
reader = csv.reader(file) | |
for row in reader: | |
first_name, last_name, phone = row | |
contact = InputPhoneContact(random.randint(0, 9999), phone, first_name, last_name) | |
contacts = client(functions.contacts.ImportContactsRequest([contact])) | |
a1 = contacts.to_dict()['users'][0]['username'] | |
a2 = contacts.to_dict()['users'][0]['phone'] | |
a3 = contacts.to_dict()['users'][0]['id'] | |
print(a1, a2, a3, file=open('tlogs', 'a')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment