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)
找到了api_id和api_hash,但是没有找到session_hash
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))
session_hash 不需要您手动获取。当您使用 Telethon 客户端登录 Telegram 帐户时,它由 telethon 库自动生成。
session_hash 是您与 Telegram API 的会话的唯一标识符。只要您使用相同的 session_hash 和 api_id 以及 api_hash,它就允许您稍后恢复会话,而无需再次登录。
如果您使用 telebot 库创建 Telegram 机器人,则无需提供 session_hash。相反,您可以使用机器人 API 令牌来验证您的机器人并从 Telegram API 接收更新。
要获取您的 Telegram 帐户的 API ID 和哈希值,您可以按照以下步骤操作:
在网络浏览器中打开 https://my.telegram.org/auth 并登录您的 Telegram 帐户。
登录后,您应该会看到一个包含应用程序列表的页面。单击“API 开发工具”链接。
在下一页上,您应该会看到一个可以注册新申请的表格。使用所需信息填写表单,然后提交以创建新应用程序。
创建应用程序后,您应该会看到一个包含应用程序的 API ID 和哈希的页面。这些是您需要用来验证 Telethon 客户端或 Telebot 机器人的值。
该形式的 url 是什么?我不知道。