Last active
May 20, 2022 06:58
-
-
Save CustomIcon/a962053866460dc54342b8b5fa69a833 to your computer and use it in GitHub Desktop.
Recover your Voip or Test number after you loose it (if you have session string). Pyrogram and Telethon Only!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for those who uses heroku or AUTH key they can recover their account back after loosing test number or Voip. (specially for iraninan friends) | |
# | |
# DISCLAIMER: IF YOU USE THIS SNIPPET AGAINST TELEGRAM TOS YOU WILL BE BANNED FROM USING MY SERVICES | |
# | |
# STEPS: | |
# 0. fill in your api_id and api_hash variables | |
# 1. try to make telegram send you the login code from your official client | |
# 2. run the script in machine (requires pyrogram==1.0.7 and telethon==1.17.5) | |
from telethon import sync, sessions | |
from pyrogram import Client | |
api_id = 0 # your api_id | |
api_hash = '' # your api_hash | |
print('Make sure you put a Session string you are currently not using') | |
pick = input('Pyrogram or Telethon: (Choose one: p / t): ') | |
if pick =='t': | |
ses = input('Enter your Telethon SessionString: ') | |
else: | |
ses = input('Enter your Pyrogram AUTH key: ') | |
text = """ | |
=========================== | |
Your Stats: | |
------------- | |
User_ID: {user_id} | |
Username: @{username} | |
Phone_Number: +{phone} | |
=========================== | |
Last Message from Telegram Login: | |
------------- | |
{tg_lastmsg} | |
""" | |
if pick =='t': | |
with sync.TelegramClient(sessions.StringSession(ses), api_id=api_id, api_hash=api_hash) as c: | |
msgs = [] | |
for message in c.iter_messages(777000, search='Login Code:'): | |
msgs.append(message) | |
tg_lastmsg = msgs[0].text | |
me = c.get_me() | |
user_id = me.id | |
username = me.username or None | |
phone = me.phone | |
print( | |
text.format( | |
user_id=user_id, | |
username=username, | |
phone=phone, | |
tg_lastmsg=tg_lastmsg | |
) | |
) | |
else: | |
with Client(ses, api_id=api_id, api_hash=api_hash) as c: | |
for result in c.search_messages(777000, query='Login Code:', limit=1): | |
tg_lastmsg = result.text | |
me = c.get_me() | |
user_id = me.id | |
username = me.username or None | |
phone = me.phone_number | |
print( | |
text.format( | |
user_id=user_id, | |
username=username, | |
phone=phone, | |
tg_lastmsg=tg_lastmsg | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment