A
A
aqau1232021-12-10 20:29:11
Python
aqau123, 2021-12-10 20:29:11

How to use telethon private proxies?

class TG(object):
    def __init__(self, sessionFile: str, apiId: str, apiHash: str, proxy = None) -> None:
        self.sessionFile = sessionFile
        self.apiId = apiId
        self.apiHash = apiHash
        self.proxy = proxy
        self.client: TelegramClient = None

    async def auth(self) -> None:
        self.client = TelegramClient(session=self.sessionFile,
                                     api_id=self.apiId,
                                     api_hash=self.apiHash,
                                     proxy=self.proxy)
        await self.client.start()

    async def changeUserData(self) -> None:
        await self.client(functions.account.UpdateProfileRequest(
            first_name=random.choice(Files.Files.readFile(os.path.join(os.getcwd(), 'data', 'names.txt'))),
            last_name=random.choice(Files.Files.readFile(os.path.join(os.getcwd(), 'data', 'surnames.txt'))),
        ))


How to use proxies and how to check if they work?
I have private proxies in the format: ip:port:login:password.
Proxy https ipv4, heard that telethon doesn't work with ipv6.
Tried to google it, but it doesn't work.
How to pass them to the constructor?
And how do you make sure they work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2021-12-13
@dimonchik2013

you understand what the joke is - you authenticate with the key, what's the use of proxies to you?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question