skip to Main Content

https://github.com/Eloise1988/OPENAI/blob/main/asyncV2/README.md

api_id: Telegram API ID and Hash (you can get it from my.telegram.org) api_hash : Telegram API Hash (you can get it from my.telegram.org) session_hash : Telegram Session Hash (you can get it from my.telegram.org)

1

I found api_id and api_hash, but I didn’t find session_hash

2

Answers


  1. from telethon import TelegramClient
    
    api_id = 123456  # Your API ID
    api_hash = 'your_api_hash'  # Your API Hash
    
    # Create a new TelegramClient instance and start the client
    async with TelegramClient('session_file', api_id, api_hash) as client:
        # Connect to the Telegram servers and log in
        await client.start()
    
        # After logging in, the session hash will be automatically generated and stored
        # in the 'session_file' file, which you can use in future runs to log in with
        # the same session:
        session_hash = client.session.save()
    
        print(str(session_hash))
    
    Login or Signup to reply.
  2. The session_hash is not something that you need to obtain manually. It is automatically generated by the telethon library when you log in to your Telegram account using the Telethon client.

    The session_hash is a unique identifier for your session with the Telegram API. It allows you to resume your session later, without having to log in again, as long as you use the same session_hash and api_id and api_hash.

    If you are using the telebot library to create a Telegram bot, you do not need to provide a session_hash. Instead, you can use the bot API token to authenticate your bot and receive updates from the Telegram API.

    To obtain the API ID and hash for your Telegram account, you can follow these steps:

    Open https://my.telegram.org/auth in your web browser and log in to your Telegram account.

    Once you are logged in, you should see a page with a list of your apps. Click on the "API development tools" link.

    On the next page, you should see a form where you can register a new application. Fill out the form with the requested information, and submit it to create a new app.

    After you create the app, you should see a page with your app’s API ID and hash. These are the values that you need to use to authenticate your Telethon client or telebot bot.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search