Advertisement
Guest User

Untitled

a guest
Sep 13th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.92 KB | None | 0 0
  1. # Script1.py
  2. from pyrogram import Client, Filters
  3.  
  4. var phone = "Новый номер для регистрации";
  5. api_id, api_hash = "API ключи аккаунта, с", "которого будет происходить регистрация"
  6.  
  7. def phone_code_callback(phone_number):
  8.     code = input("Код подтверждения номера телефона: ")
  9.     return code
  10.  
  11. app = Client(
  12.     phone,
  13.     api_id=api_id,
  14.     api_hash=api_hash,
  15.     phone_number=phone,
  16.     phone_code=phone_code_callback,
  17.     first_name="Harry",
  18.     last_name="Potter",
  19.     app_version="1.0.0",
  20.     device_model="PC",
  21.     system_version="Linux",
  22.     lang_code="en",
  23.     proxy=dict(
  24.         hostname="xxx.xxx.xxx.xxx",
  25.         port=xxxx,
  26.         username="xxxxxx",
  27.         password="xxxxxx"
  28.     )
  29. )
  30.  
  31. app.start()
  32.  
  33. # Библиотека (Pyrogram) отвечает "Login successful"
  34. # ...создается файл сессии (*.session)
  35. # Переходим на https://my.telegram.org/apps
  36. # Вводим номер телефона (phone), получаем код...
  37.  
  38. @app.on_message(Filters.private)
  39. def echo(client, message):
  40.     #print(message.text)
  41.     passw=re.findall(r'Telegram website:\s(.*?)\s', message.text)
  42.     if len(passw)!=0:
  43.         passw=passw[0]
  44.         print("Код авторизации:   %s"%passw)
  45.  
  46. # Регистрируем приложение, получаем API ключи
  47.  
  48. ##################################################
  49.  
  50. # Script2.py
  51. from pyrogram import Client
  52. api_id, api_hash = "новые API ключи, ", "которые мы получили при регистрация"
  53.  
  54. app = Client(
  55.     file_session_name,
  56.     api_id = api_id,
  57.     api_hash = api_hash,
  58.     proxy=dict(
  59.         hostname="xxx.xxx.xxx.xxx",
  60.         port=xxxx,
  61.         username="xxxxxx",
  62.         password="xxxxxx"
  63.     )
  64. )
  65.  
  66. app.start()
  67. userid=app.resolve_peer("@superuser314").user_id
  68. print(userid)
  69.  
  70. # pyrogram.api.errors.exceptions.unauthorized_401.Unauthorized
  71. # The user has been deleted/deactivated
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement