main.py 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. from sys import exit
  2. from time import sleep
  3. from config import (
  4. REFERRAL_DATABASE_FILE_PATH,
  5. FROM_VERIFICATION_MAIL,
  6. SUBJECT_VERIFICATION_MAIL,
  7. REFERRAL_CODE,
  8. )
  9. import db
  10. from steps import *
  11. from utils import *
  12. def create_account(referral_code=REFERRAL_CODE):
  13. account_data = {
  14. 'alliance_name': get_random_alliance_name(),
  15. 'cookies': None,
  16. 'email': get_email(),
  17. 'first_name': get_random_first_name(),
  18. 'last_name': get_random_last_name(),
  19. 'password': get_random_password(),
  20. 'proxy': get_proxy(),
  21. 'referral_code': referral_code,
  22. 'registration_date': get_current_datetime(),
  23. 'username': get_random_username(),
  24. 'user_agent': get_random_user_agent(),
  25. 'user_id': None,
  26. 'wallet': get_random_wallet(),
  27. }
  28. logger.debug(account_data)
  29. get_server_time_result = get_server_time(
  30. proxies=account_data['proxy']['proxies'],
  31. user_agent=account_data['user_agent']
  32. )
  33. if get_server_time_result['status'] != 'success':
  34. logger.error(f'code: YcEp5ZdU;')
  35. return {'status': 'error'}
  36. server_time = get_server_time_result['data']['time']
  37. message = f'{{"created_on":"{server_time}"}}'
  38. wallet_sign_message_result = wallet_sign_message(
  39. message=message,
  40. private_key=account_data['wallet']['private_key']
  41. )
  42. connect_wallet_result = connect_wallet(
  43. wallet_address=account_data['wallet']['address'],
  44. signed_message=wallet_sign_message_result,
  45. message=message,
  46. proxies=account_data['proxy']['proxies'],
  47. user_agent=account_data['user_agent'],
  48. )
  49. if connect_wallet_result['status'] != 'success':
  50. logger.error(f'code: PMv2hJus;')
  51. return {'status': 'error'}
  52. account_data['cookies'] = connect_wallet_result['data']['cookies']
  53. account_data['user_id'] = connect_wallet_result['data']['account']['user_id']
  54. check_profile_result = check_profile(
  55. cookies=account_data['cookies'],
  56. proxies=account_data['proxy']['proxies'],
  57. user_agent=account_data['user_agent'],
  58. )
  59. if check_profile_result['status'] != 'success':
  60. logger.error(f'code: y92Gn7dJ;')
  61. return {'status': 'error'}
  62. choice_alliance_result = choice_alliance(
  63. alliance_id=account_data['alliance_name'],
  64. cookies=account_data['cookies'],
  65. proxies=account_data['proxy']['proxies'],
  66. user_agent=account_data['user_agent'],
  67. )
  68. if choice_alliance_result['status'] != 'success':
  69. logger.error(f'code: x3BwYnRq;')
  70. return {'status': 'error'}
  71. create_account_mission_result = create_account_mission(
  72. first_name=account_data['first_name'],
  73. last_name=account_data['last_name'],
  74. username=account_data['username'],
  75. password=account_data['password'],
  76. email=account_data['email'],
  77. referral_code=referral_code,
  78. cookies=account_data['cookies'],
  79. proxies=account_data['proxy']['proxies'],
  80. user_agent=account_data['user_agent'],
  81. )
  82. if create_account_mission_result['status'] != 'success':
  83. logger.error(f'code: H33zbqVr;')
  84. return {'status': 'error'}
  85. get_email_verification_url_result = get_email_verification_url(
  86. email=account_data['email'],
  87. _from=FROM_VERIFICATION_MAIL,
  88. subject=SUBJECT_VERIFICATION_MAIL,
  89. proxies=account_data['proxy']['proxies'],
  90. without_mail_id=None
  91. )
  92. if get_email_verification_url_result['status'] != 'success':
  93. if get_email_verification_url_result['status'] == 'again':
  94. pass
  95. else:
  96. logger.error('code: ZJU9uVz8')
  97. verify_email_result = verify_email_with_requests(
  98. url=get_email_verification_url_result['data']['url'],
  99. proxies=account_data['proxy']['proxies'],
  100. user_agent=account_data['user_agent'],
  101. )
  102. if verify_email_result['status'] != 'success':
  103. logger.error('code: 9rW2QC4w')
  104. return {'status': 'error'}
  105. check_profile_result = check_profile(
  106. cookies=account_data['cookies'],
  107. proxies=account_data['proxy']['proxies'],
  108. user_agent=account_data['user_agent'],
  109. )
  110. if check_profile_result['status'] != 'success':
  111. logger.error(f'code: Rk6ta6xk;')
  112. return {'status': 'error'}
  113. return {
  114. 'status': 'success',
  115. 'data': {
  116. 'account': account_data
  117. }
  118. }
  119. def main(i):
  120. logger.info(f'start create new referral: {i}')
  121. sleep(10)
  122. referral_account = create_account()
  123. if referral_account['status'] != 'success':
  124. logger.error('cannot create referral..')
  125. return {'status': 'error'}
  126. db.create_row(referral_account['data']['account'], _file=REFERRAL_DATABASE_FILE_PATH)
  127. logger.info(['Данные: ', referral_account['data']['account']])
  128. logger.info(f'Аккаунт {i} успешно создан!\n')
  129. if __name__ == '__main__':
  130. logger.info('init databases')
  131. db.init(_file=REFERRAL_DATABASE_FILE_PATH)
  132. logger.info('run programm')
  133. for i in range(1, REFERRALS_COUNT+1):
  134. while True:
  135. sleep(5)
  136. try:
  137. main(i)
  138. break
  139. except Exception as e:
  140. logger.error(e)
  141. sleep(10)
  142. input('\npress enter to exit..')