steps.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. # IMPORTS
  2. from time import sleep
  3. from http import cookies
  4. import requests
  5. # from requests_html import HTMLSession
  6. from log import logger
  7. from utils import parse_1secmail_mail
  8. # SETUP
  9. from requests.packages.urllib3 import disable_warnings
  10. from requests.packages.urllib3.exceptions import InsecureRequestWarning
  11. disable_warnings(InsecureRequestWarning)
  12. # MAIN
  13. def check_profile(cookies, proxies, user_agent):
  14. if cookies:
  15. cookies = {
  16. 'session': cookies['session'],
  17. 'access_token': cookies['access_token'],
  18. 'refresh_token': cookies['refresh_token'],
  19. }
  20. headers = {
  21. 'Host': 'myriaverse-api.myria.com',
  22. 'User-Agent': user_agent,
  23. 'Accept': 'application/json',
  24. 'Accept-Language': 'en-US,en;q=0.5',
  25. # 'Accept-Encoding': 'gzip, deflate',
  26. 'Referer': 'https://myriaverse-api.myria.com/',
  27. 'Cache-Control': 'no-cache',
  28. 'Origin': 'https://myria.com',
  29. 'Dnt': '1',
  30. 'Sec-Fetch-Dest': 'empty',
  31. 'Sec-Fetch-Mode': 'cors',
  32. 'Sec-Fetch-Site': 'same-site',
  33. 'Sec-Gpc': '1',
  34. # Requests doesn't support trailers
  35. # 'Te': 'trailers',
  36. # Requests sorts cookies= alphabetically
  37. # 'Cookie': f'session={session}; access_token={access_token}; refresh_token={refresh_token}',
  38. }
  39. sleep(10)
  40. response = requests.get(
  41. 'https://myriaverse-api.myria.com/v1/sigil/users/profile',
  42. cookies=cookies, headers=headers, proxies=proxies, verify=False
  43. )
  44. if response.status_code != 200:
  45. logger.error(f'code: 9vcqdDXt; {response.status_code} {response.text}')
  46. return {'status': 'error'}
  47. if not response.text or not response.json():
  48. logger.error(f'code: 6NqGfM43; {response.text}')
  49. return {'status': 'error'}
  50. if response.json()['status'] != 'success':
  51. logger.error(f'code: GV8u9QBc;{response.text}')
  52. return {'status': 'error'}
  53. return {
  54. 'status': 'success',
  55. 'data': response.json()['data']
  56. }
  57. def get_server_time(proxies, user_agent):
  58. headers = {
  59. 'Host': 'myriaverse-api.myria.com',
  60. 'User-Agent': user_agent,
  61. 'Accept': 'application/json',
  62. 'Accept-Language': 'en-US,en;q=0.5',
  63. # 'Accept-Encoding': 'gzip, deflate',
  64. 'Referer': 'https://myriaverse-api.myria.com/',
  65. 'Origin': 'https://myria.com',
  66. 'Dnt': '1',
  67. 'Sec-Fetch-Dest': 'empty',
  68. 'Sec-Fetch-Mode': 'cors',
  69. 'Sec-Fetch-Site': 'same-site',
  70. 'Sec-Gpc': '1',
  71. # Requests doesn't support trailers
  72. # 'Te': 'trailers',
  73. }
  74. sleep(5)
  75. response = requests.get(
  76. 'https://myriaverse-api.myria.com/v1/time',
  77. headers=headers, proxies=proxies, verify=False
  78. )
  79. if response.status_code != 200:
  80. logger.error(f'code: tXdG66MU; {response.status_code} {response.text}')
  81. return {'status': 'error'}
  82. if not response.text or not response.json():
  83. logger.error(f'code: eyrErC4m; {response.text}')
  84. return {'status': 'error'}
  85. if response.json()['status'] != 'success':
  86. logger.error(f'code: 5CB6nm78;{response.text}')
  87. return {'status': 'error'}
  88. if not response.json()['data']:
  89. logger.error(f'code: 9TEttF6r;{response.text}')
  90. return {'status': 'error'}
  91. return {
  92. 'status': 'success',
  93. 'data': {
  94. 'time': response.json()['data']['time']
  95. }
  96. }
  97. def connect_wallet(wallet_address, signed_message, message, proxies, user_agent):
  98. headers = {
  99. 'Host': 'myriaverse-api.myria.com',
  100. 'User-Agent': user_agent,
  101. 'Accept': 'application/json',
  102. 'Accept-Language': 'en-US,en;q=0.5',
  103. # 'Accept-Encoding': 'gzip, deflate',
  104. 'Referer': 'https://myriaverse-api.myria.com/',
  105. # Already added when you pass json=
  106. # 'Content-Type': 'application/json',
  107. # 'Content-Length': '263',
  108. 'Origin': 'https://myria.com',
  109. 'Dnt': '1',
  110. 'Sec-Fetch-Dest': 'empty',
  111. 'Sec-Fetch-Mode': 'cors',
  112. 'Sec-Fetch-Site': 'same-site',
  113. 'Sec-Gpc': '1',
  114. # Requests doesn't support trailers
  115. # 'Te': 'trailers',
  116. }
  117. json_data = {
  118. 'wallet_id': wallet_address,
  119. 'signature': signed_message,
  120. 'message': message,
  121. }
  122. sleep(5)
  123. response = requests.post(
  124. 'https://myriaverse-api.myria.com/v1/accounts/login/wallet',
  125. headers=headers, json=json_data, proxies=proxies, verify=False
  126. )
  127. if response.status_code != 200:
  128. logger.error(f'code: Rw5dH6WF; {response.status_code} {response.text}')
  129. return {'status': 'error'}
  130. if not response.text or not response.json():
  131. logger.error(f'code: Ecedn2Up; {response.text}')
  132. return {'status': 'error'}
  133. if response.json()['status'] != 'success':
  134. logger.error(f'code: X89HrtH8;{response.text}')
  135. return {'status': 'error'}
  136. if not response.json()['data']:
  137. logger.error(f'code: Wyd3zYfV;{response.text}')
  138. return {'status': 'error'}
  139. return {
  140. 'status': 'success',
  141. 'data': {
  142. 'cookies': {
  143. 'session': response.cookies['session'],
  144. 'access_token': response.cookies['access_token'],
  145. 'refresh_token': response.cookies['refresh_token']
  146. },
  147. 'account': {
  148. 'user_id': response.json()['data']['user_id'],
  149. 'updated_on': response.json()['data']['updated_on'],
  150. 'wallet_id': response.json()['data']['wallet_id'],
  151. 'user_roles': response.json()['data']['user_roles'],
  152. 'last_activity': response.json()['data']['last_activity'],
  153. 'created_on': response.json()['data']['created_on']
  154. }
  155. }
  156. }
  157. def choice_alliance(alliance_id, cookies, proxies, user_agent):
  158. cookies = {
  159. 'session': cookies['session'],
  160. 'access_token': cookies['access_token'],
  161. 'refresh_token': cookies['refresh_token'],
  162. }
  163. headers = {
  164. 'Host': 'myriaverse-api.myria.com',
  165. 'User-Agent': user_agent,
  166. 'Accept': 'application/json',
  167. 'Accept-Language': 'en-US,en;q=0.5',
  168. # 'Accept-Encoding': 'gzip, deflate',
  169. 'Referer': 'https://myriaverse-api.myria.com/',
  170. # Already added when you pass json=
  171. # 'Content-Type': 'application/json',
  172. # 'Content-Length': '30',
  173. 'Origin': 'https://myria.com',
  174. 'Dnt': '1',
  175. 'Sec-Fetch-Dest': 'empty',
  176. 'Sec-Fetch-Mode': 'cors',
  177. 'Sec-Fetch-Site': 'same-site',
  178. 'Sec-Gpc': '1',
  179. # Requests doesn't support trailers
  180. # 'Te': 'trailers',
  181. # Requests sorts cookies= alphabetically
  182. # 'Cookie': f'session={session}; access_token={access_token}; refresh_token={refresh_token}',
  183. }
  184. json_data = {
  185. 'alliance_id': alliance_id,
  186. }
  187. sleep(5)
  188. response = requests.post(
  189. 'https://myriaverse-api.myria.com/v1/sigil/users/alliance',
  190. cookies=cookies, headers=headers, json=json_data, proxies=proxies, verify=False
  191. )
  192. if response.status_code != 200:
  193. logger.error(f'code: 6R8mJJmP; {response.status_code} {response.text}')
  194. return {'status': 'error'}
  195. if not response.text or not response.json():
  196. logger.error(f'code: 3dC5YSXE; {response.text}')
  197. return {'status': 'error'}
  198. if response.json()['status'] != 'success':
  199. logger.error(f'code: j5pyAKk3;{response.text}')
  200. return {'status': 'error'}
  201. return {
  202. 'status': 'success',
  203. 'data': {}
  204. }
  205. def create_account_mission(first_name, last_name, username, password, email, referral_code, cookies, proxies, user_agent):
  206. cookies = {
  207. 'session': cookies['session'],
  208. 'access_token': cookies['access_token'],
  209. 'refresh_token': cookies['refresh_token'],
  210. }
  211. headers = {
  212. 'Host': 'myriaverse-api.myria.com',
  213. 'User-Agent': user_agent,
  214. 'Accept': 'application/json',
  215. 'Accept-Language': 'en-US,en;q=0.5',
  216. # 'Accept-Encoding': 'gzip, deflate',
  217. 'Referer': 'https://myriaverse-api.myria.com/',
  218. # Already added when you pass json=
  219. # 'Content-Type': 'application/json',
  220. # 'Content-Length': '145',
  221. 'Origin': 'https://myria.com',
  222. 'Dnt': '1',
  223. 'Sec-Fetch-Dest': 'empty',
  224. 'Sec-Fetch-Mode': 'cors',
  225. 'Sec-Fetch-Site': 'same-site',
  226. 'Sec-Gpc': '1',
  227. # Requests doesn't support trailers
  228. # 'Te': 'trailers',
  229. # Requests sorts cookies= alphabetically
  230. # 'Cookie': f'session={session}; access_token=access_token; refresh_token={refresh_token}',
  231. }
  232. json_data = {
  233. 'first_name': first_name,
  234. 'last_name': last_name,
  235. 'username': username,
  236. 'password': password,
  237. 'email': email,
  238. 'redirect': 0,
  239. }
  240. if referral_code: json_data['referral_code'] = referral_code
  241. sleep(5)
  242. response = requests.post(
  243. 'https://myriaverse-api.myria.com/v1/accounts/link',
  244. cookies=cookies, headers=headers, json=json_data, verify=False
  245. )
  246. # print(cookies, headers, json_data)
  247. if response.status_code != 200:
  248. logger.error(f'code: tLV5YRmc; {response.status_code} {response.text}')
  249. return {'status': 'error'}
  250. if not response.text or not response.json():
  251. logger.error(f'code: DVz2M5UC; {response.text}')
  252. return {'status': 'error'}
  253. if response.json()['status'] != 'success':
  254. logger.error(f'code: 9mtBJSdU;{response.text}')
  255. return {'status': 'error'}
  256. if not response.json()['data']:
  257. logger.error(f'code: GGeaTG53;{response.text}')
  258. return {'status': 'error'}
  259. return {
  260. 'status': 'success',
  261. 'data': response.json()['data']
  262. }
  263. def get_email_verification_url(email, _from, subject, proxies, without_mail_id=None):
  264. parse_1secmail_mail_result = parse_1secmail_mail(email, _from, subject, proxies)
  265. if parse_1secmail_mail_result['status'] != 'success':
  266. logger.error('code: uNFr5wAn')
  267. return {'status': 'error'}
  268. mail_text_body = parse_1secmail_mail_result['data']['json']['textBody']
  269. url = mail_text_body[60:] # replace 'Please click the below url to verify your registration:\n '
  270. return {
  271. 'status': 'success',
  272. 'data': {
  273. 'url': url
  274. }
  275. }
  276. def verify_email_with_requests(url, proxies, user_agent):
  277. headers = {
  278. 'Host': 'myriaverse-api.myria.com',
  279. 'User-Agent': user_agent,
  280. 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
  281. 'Accept-Language': 'en-US,en;q=0.5',
  282. # 'Accept-Encoding': 'gzip, deflate',
  283. 'Dnt': '1',
  284. 'Upgrade-Insecure-Requests': '1',
  285. 'Sec-Fetch-Dest': 'document',
  286. 'Sec-Fetch-Mode': 'navigate',
  287. 'Sec-Fetch-Site': 'none',
  288. 'Sec-Fetch-User': '?1',
  289. 'Sec-Gpc': '1',
  290. # Requests doesn't support trailers
  291. # 'Te': 'trailers',
  292. }
  293. sleep(10)
  294. response = requests.get(url, headers=headers, proxies=proxies, verify=False)
  295. logger.debug(f'\n\n{response.status_code} {response.text}\n\n')
  296. # if response.status_code != 200:
  297. # logger.error(f'code: TvF5R7Tx; {response.status_code} {response.text}')
  298. # return {'status': 'error'}
  299. # if not response.text:
  300. # logger.error(f'code: XWtz7R72; {response.text}')
  301. # return {'status': 'error'}
  302. # data = '<p>Found. Redirecting to <a href="https://myria.com/sigil">https://myria.com/sigil</a></p>'
  303. # if not data in response.text:
  304. # logger.error(f'code: EWd6bW9h; {response.text}')
  305. # return {'status': 'error'}
  306. return {'status': 'success'}
  307. def verify_email(url, proxies, user_agent):
  308. session = HTMLSession()
  309. response = session.get(url, proxies=proxies, timeout=(27,27), verify=False)
  310. # response.html.render(timeout=27)
  311. if response.status_code != 200:
  312. logger.error(f'code: ed4qK5X6; {response.status_code} {response.text}')
  313. return {'status': 'error'}
  314. if not response.text:
  315. logger.error(f'code: fUq7r9JW; {response.text}')
  316. return {'status': 'error'}
  317. # data = '<p>Found. Redirecting to <a href="https://myria.com/sigil">https://myria.com/sigil</a></p>'
  318. # if not data in response.text:
  319. # logger.error(f'code: M4e4LvED; {response.text}')
  320. # return {'status': 'error'}
  321. data = 'Myria is a blockchain gaming ecosystem powered by'
  322. if not data in response.text:
  323. logger.error(f'code: M4e4LvED; {response.text}')
  324. return {'status': 'error'}
  325. return {'status': 'success'}