N
N
nazlanmak2021-03-03 12:51:18
Python
nazlanmak, 2021-03-03 12:51:18

How to change bot account?

It is necessary that the code works on another account (and preferably on all), I changed api_id, api_hash, it does not help. At the first start in cmd, it was necessary to perform authorization, how can I do it again?

from telethon import TelegramClient, events, sync

api_id = 
api_hash = '' 

client = TelegramClient('session_name', api_id, api_hash)
client.start()

with TelegramClient('name', api_id, api_hash) as client:
    client.send_message('me', 'Hello, myself!')
    print(client.download_profile_photo('me'))

    @client.on(events.NewMessage(pattern='(?i).*123'))
    async def handler(event):
        await event.respond('456')

    client.run_until_disconnected()

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nazlanmak, 2021-03-03
@nazlanmak

Ended the session through the mobile app

A
Alexander Kovalenko, 2021-03-03
@KovalenkoA12

a file with a session is created there in your case (session_name.session), in order to re-authorize you need to delete this file and when you restart it is created again
This file is needed to save your data and not enter them by re-running the script

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question