import cv2
import numpy as np
import pytesseract
from PIL import ImageGrab
import time
import re
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
# захватываем всю верхнюю треть экрана с запасом
CROP_BOX = (200, 0, 1400, 300)
total_rub = 0
total_usd = 0
last_text = ""
print("Скрипт палит донаты в расширенном режиме...")
while True:
try:
img = ImageGrab.grab(bbox=CROP_BOX)
img_np = np.array(img)
img_bgr = cv2.cvtColor(img_np, cv2.COLOR_RGB2BGR)
# 1. обычный текст без фильтра цвета
text_raw = pytesseract.image_to_string(img_bgr, lang='eng').strip()
# 2. текст с красным фильтром
hsv = cv2.cvtColor(img_np, cv2.COLOR_RGB2HSV)
lower_red1 = np.array([0, 80, 80])
upper_red1 = np.array([15, 255, 255])
lower_red2 = np.array([165, 80, 80])
upper_red2 = np.array([180, 255, 255])
mask = cv2.inRange(hsv, lower_red1, upper_red1) + cv2.inRange(hsv, lower_red2, upper_red2)
text_red = pytesseract.image_to_string(mask, lang='eng').strip()
full_text = f"{text_raw} {text_red}"
if full_text and full_text != last_text:
# ищем рубли
rub_match = re.search(r'(\d[\d\s]*)\s*(?:RUB|RUBI|RUB!|руб|\$)', full_text, re.IGNORECASE)
# ищем баксы
usd_match = re.search(r'(\d[\d\s]*)\s*(?:USD|USDI|USD!)', full_text, re.IGNORECASE)
if rub_match:
raw_val = rub_match.group(1).replace(' ', '')
if raw_val.isdigit():
amount = int(raw_val)
if 100 <= amount <= 100000:
total_rub += amount
print(f"[+] Донат: {amount} RUB | Всего рублей: {total_rub}")
last_text = full_text
time.sleep(4)
elif usd_match:
raw_val = usd_match.group(1).replace(' ', '')
if raw_val.isdigit():
amount = int(raw_val)
if 1 <= amount <= 3000:
total_usd += amount
print(f"[+] Донат: {amount} USD | Всего баксов: {total_usd}")
last_text = full_text
time.sleep(4)
except Exception as e:
pass
time.sleep(1)