bot_V2.py 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. from selenium import webdriver
  2. from selenium.webdriver.common.by import By
  3. from selenium.webdriver.support.ui import WebDriverWait
  4. from selenium.webdriver.support import expected_conditions as EC
  5. from telethon import sync, events
  6. import requests
  7. import json
  8. import hashlib
  9. import time
  10. import re
  11. from telethon import TelegramClient
  12. import webbrowser
  13. import urllib.request
  14. import os
  15. import sqlite3
  16. class RunChromeTests():
  17. def testMethod(self):
  18. selenium_url = "http://localhost:4444/wd/hub"
  19. caps = {'browserName': 'chrome'}
  20. driver = webdriver.Remote(command_executor=selenium_url, desired_capabilities=caps)
  21. driver.maximize_window()
  22. driver.get(url_rec)
  23. time.sleep(waitin + 10)
  24. driver.close()
  25. driver.quit()
  26. db = sqlite3.connect('Account.db')
  27. cur = db.cursor()
  28. x = 1
  29. while(True):
  30. n = 0
  31. u = 0
  32. print("Очередь аккаунта № " + str(x))
  33. if x == 23:
  34. x = x - 22
  35. cur.execute(f"SELECT PHONE FROM Account WHERE ID = '{x}'")
  36. time.sleep(0.4)
  37. Phone = str(cur.fetchone()[0])
  38. print("Входим в аккаунт: " + Phone)
  39. cur.execute(f"SELECT API_ID FROM Account WHERE ID = '{x}'")
  40. time.sleep(0.4)
  41. api_id = str(cur.fetchone()[0])
  42. cur.execute(f"SELECT API_HASH FROM Account WHERE ID = '{x}'")
  43. time.sleep(0.4)
  44. api_hash = str(cur.fetchone()[0])
  45. session = str("anon" + str(x))
  46. client = TelegramClient(session, api_id, api_hash)
  47. client.start()
  48. dlgs = client.get_dialogs()
  49. for dlg in dlgs:
  50. if dlg.title == 'LTC Click Bot':
  51. tegmo = dlg
  52. client.send_message('LTC Click Bot', "🖥 Visit sites")
  53. time.sleep(30)
  54. while True:
  55. time.sleep(6)
  56. print("Нет заданий уже: " + str(u) + " раз")
  57. if u == 2:
  58. print("Переходим на другой аккаунт")
  59. break
  60. print("Пройдено циклов: " + str(n))
  61. if n == 10:
  62. print("Переходим на другой аккаунт")
  63. break
  64. msgs = client.get_messages(tegmo, limit=1)
  65. for mes in msgs:
  66. if re.search(r'\bseconds to get your reward\b', mes.message):
  67. print("Найдено reward")
  68. str_a = str(mes.message)
  69. zz = str_a.replace('You must stay on the site for', '')
  70. qq = zz.replace('seconds to get your reward.', '')
  71. waitin = int(qq)
  72. print ("Ждать придется: ", waitin)
  73. client.send_message('LTC Click Bot', "/visit")
  74. time.sleep(3)
  75. msgs2 = client.get_messages(tegmo, limit=1)
  76. for mes2 in msgs2:
  77. button_data = mes2.reply_markup.rows[1].buttons[1].data
  78. message_id = mes2.id
  79. print("Перехожу по ссылке")
  80. time.sleep(2)
  81. url_rec = messages[0].reply_markup.rows[0].buttons[0].url
  82. ch = RunChromeTests()
  83. ch.testMethod()
  84. time.sleep(6)
  85. fp = urllib.request.urlopen(url_rec)
  86. mybytes = fp.read()
  87. mystr = mybytes.decode("utf8")
  88. fp.close()
  89. if re.search(r'\bSwitch to reCAPTCHA\b', mystr):
  90. from telethon.tl.functions.messages import GetBotCallbackAnswerRequest
  91. resp = client(GetBotCallbackAnswerRequest(
  92. 'LTC Click Bot',
  93. message_id,
  94. data=button_data
  95. ))
  96. time.sleep(2)
  97. print("КАПЧА!")
  98. else:
  99. time.sleep(waitin)
  100. time.sleep(2)
  101. elif re.search(r'\bSorry\b', mes.message):
  102. print("Найдено Sorry")
  103. u = u + 1
  104. print(u)
  105. else:
  106. messages = client.get_messages('Litecoin_click_bot')
  107. url_rec = messages[0].reply_markup.rows[0].buttons[0].url
  108. f = open("per10.txt")
  109. fd = f.read()
  110. if fd == url_rec:
  111. print("Найдено повторение переменной")
  112. msgs2 = client.get_messages(tegmo, limit=1)
  113. for mes2 in msgs2:
  114. button_data = mes2.reply_markup.rows[1].buttons[1].data
  115. message_id = mes2.id
  116. from telethon.tl.functions.messages import GetBotCallbackAnswerRequest
  117. resp = client(GetBotCallbackAnswerRequest(
  118. tegmo,
  119. message_id,
  120. data=button_data
  121. ))
  122. time.sleep(2)
  123. else:
  124. waitin = 15
  125. data1 = requests.get(url_rec).json
  126. print(data1)
  127. my_file = open('per10.txt', 'w')
  128. my_file.write(url_rec)
  129. print("Новая запись в файле сделана")
  130. time.sleep(16)
  131. n = n + 1
  132. if n == 10:
  133. break
  134. time.sleep(1)
  135. x = x + 1
  136. if x == 23:
  137. break