我在 pyrogram 中制作了一个程序,它在以前的电报帐户上运行良好,但是当有人使用新帐户登录时,更新应用程序时出错,我已更新它并更改了登录代码,但当我使用该会话字符串时在我的应用程序中它不起作用
这是我如何创建会话的代码
# Session creator
from pyrogram import Client
import os
# os.system('pip install --upgrade pip')
# os.system('pip install Pyrogram==1.2.20')
banner = """
_ _
___ ___ ___ ___(_) ___ _ __ ___ _ __ ___ __ _| |_ ___ _ __
/ __|/ _ \/ __/ __| |/ _ \| '_ \ / __| '__/ _ \/ _` | __/ _ \| '__|
\__ \ __/\__ \__ \ | (_) | | | | | (__| | | __/ (_| | || (_) | |
|___/\___||___/___/_|\___/|_| |_| \___|_| \___|\__,_|\__\___/|_|
"""
print(banner)
print("""String Generator. ==> Get Your Api Id & Api Hash From my.telegram.org and fill accordingly."""
)
print("")
while True:
try:
APP_ID = int(input("Enter APP ID - "))
API_HASH = input("Enter API HASH - ")
with Client(":memory:", APP_ID, API_HASH) as c:
print("")
print("This is your STRING_SESSION. Please Keep It safe.")
print("")
c.storage.SESSION_STRING_FORMAT = ">B?256sQ?"
session = c.export_session_string()
with open("accounts.csv", "a")as file:
file.writelines(str(APP_ID) + "," +
str(API_HASH) + "," + str(session) + "\n")
# print(session)
print("added")
print("\n\n\n")
except KeyboardInterrupt as error:
print("stopped")
break
exit()
当我在我的程序中使用这个会话时,它给了我这个错误:
Traceback (most recent call last):
File "/home/ak/Desktop/development/bots/pyrogramplugins/multiuserbot/userbot/randombot.py", line 161, in <module>
ac.start()
File "/home/ak/.local/lib/python3.9/site-packages/pyrogram/sync.py", line 56, in async_to_sync_wrap
return loop.run_until_complete(coroutine)
File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/home/ak/.local/lib/python3.9/site-packages/pyrogram/methods/utilities/start.py", line 53, in start
is_authorized = await self.connect()
File "/home/ak/.local/lib/python3.9/site-packages/pyrogram/methods/auth/connect.py", line 39, in connect
await self.load_session()
File "/home/ak/.local/lib/python3.9/site-packages/pyrogram/client.py", line 669, in load_session
await self.storage.open()
File "/home/ak/.local/lib/python3.9/site-packages/pyrogram/storage/memory_storage.py", line 38, in open
dc_id, test_mode, auth_key, user_id, is_bot = struct.unpack(
struct.error: unpack requires a buffer of 267 bytes