I wrote a bot so that I can create a session for a user by taking their phone number. Everything works fine until the line await cli.sign_in(f'{phone_number}', f'{code.phone_code_hash}', ramz)
is called, and then the program gives the following error:
pyrogram.errors.exceptions.bad_request_400.PhoneCodeExpired: Telegram says: [400 PHONE_CODE_EXPIRED] - The confirmation code has expired (caused by "auth.SignIn")
"
my code :
@app.on_message(contacts)
async def register_mobile(client, message):
user_number = message.contact.phone_number
user_id = message.from_user.id
# create session for user with phone number
cli = Client("4984920", api_id_975, api_hash_975)
await cli.connect()
code = await cli.send_code(user_number)
print('we are here')
temp[user_id] = [cli,user_number,code]
print(temp)
await message.reply(
f"send telegram code to bot"
)
@app.on_message()
async def handler4(c,m):
print('here we are')
if (data:=temp[m.from_user.id]):
cli,phone_number,code = data
print(code)
ramz = str(m.text)
print(ramz,len(ramz),type(ramz))
await cli.sign_in(f'{phone_number}',f'{code.phone_code_hash}',ramz)
print('done')
string_session = await cli.export_session_string()
print(f"Session String:\n{string_session}")
"What is the solution? Is the issue related to the current event loop being used?"
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745673552a4639547.html
评论列表(0条)