I use a code for get all active sessions in a telegram account:
some of my code:
if step == 'delete_sessions_insert_number':
try:
phone_appid = apiid_accounts
phone_apphash = apihash_accounts
phone_proxy = cursor.execute(f"SELECT `proxy` FROM `sessions` WHERE `phonenumber` = '{text}'").fetchone()[0]
IP, port,username,password = phone_proxy.split(":")
sessions_logined = []
sessions_confirmed = []
for s in os.listdir('/root/bot/sessions/logined_sessions'):
sessions_logined.append(s.replace('.session', ''))
for s in os.listdir('/root/bot/sessions/confirmed_sessions'):
sessions_confirmed.append(s.replace('.session', ''))
if text in sessions_confirmed:
account = tc2(f"sessions/confirmed_sessions/{text}.session", api_id=int(phone_appid) , api_hash=str(phone_apphash), proxy=("socks5", IP, int(port), True, username, password))
elif text in sessions_logined:
account = tc2(f"sessions/logined_sessions/{text}.session", api_id=int(phone_appid) , api_hash=str(phone_apphash), proxy=("socks5", IP, int(port), True, username, password))
else:
await event.reply('phone number not found!', buttons=admin_cancel_markup)
return
await account.connect()
result_all_sessions = account(functions.account.GetAuthorizationsRequest())
await account.disconnect()
await event.reply(f'Sessions: n {str(result_all_sessions)}')
all things is correct but I see an Error:
'coroutine' object has no attribute 'stringify'
in telethon docs are a example for GetAuthorizationsRequest() that use .stringify but result have not this attribute.