import pyautogui import psutil import requests import time from PIL import Image, ImageDraw, ImageGrab import os import pyimgur import GPUtil # Imgur API anahtarınızı buraya ekleyin IMGUR_CLIENT_ID = '4d3b0dd651615bb' # Discord Webhook URL WEBHOOK_URL = "https://discord.com/api/webhooks/1273353871712059442/tGr_SHM_KXysnnVgKUpFcv9j9gAAVkveFemewq8oFGH6WHg-_NxDwVoijli8KQ7UpsbY" # Discord'da kullanılan özel emoji ID'leri CPU_ICON = "<:cpu:1273350373712592966>" GPU_ICON = "<:gpu:1273349785046220941>" RAM_ICON = "<:ram:1273349772270632990>" ROBLOX_ICON = "<:robblox:1273551797713244170>" def get_system_metrics(): cpu_usage = psutil.cpu_percent(interval=None) ram_usage = psutil.virtual_memory().percent gpus = GPUtil.getGPUs() gpu_usage = round(gpus[0].load * 100, 1) if gpus else 0 active_windows = count_processes("MuMuVMM") return cpu_usage, gpu_usage, ram_usage, active_windows def count_processes(prefix): count = 0 for proc in psutil.process_iter(['pid', 'name']): if proc.info['name'] and proc.info['name'].startswith(prefix): count += 1 return count def count_images_on_screen(image_path, confidence=0.992): try: found_images = list(pyautogui.locateAllOnScreen(image_path, confidence=confidence)) return found_images if found_images else [] except Exception as e: print(f"Resim bulunamadı: {e}") return [] def save_image_with_boxes(image_path, found_images, output_path, color="red"): screenshot = pyautogui.screenshot() screenshot_image = Image.frombytes('RGB', screenshot.size, screenshot.tobytes()) draw = ImageDraw.Draw(screenshot_image) for box in found_images: left, top, width, height = box right = left + width bottom = top + height draw.rectangle([left, top, right, bottom], outline=color, width=2) screenshot_image.save(output_path) def upload_image_to_imgur(image_path): im = pyimgur.Imgur(IMGUR_CLIENT_ID) uploaded_image = im.upload_image(image_path, title="Screenshot") return uploaded_image.link if uploaded_image.link else None def send_embed_to_discord(cpu_usage, gpu_usage, ram_usage, active_windows, image_url, image_count, error_image_count): description = ( f"CPU Değeri: {CPU_ICON} `{cpu_usage}/100`\n" f"GPU Değeri: {GPU_ICON} `{gpu_usage}/100`\n" f"Ram Kullanımı: {RAM_ICON} `{ram_usage}/100`\n" f"Açık Roblox: {ROBLOX_ICON} `{image_count}`\n" ) if error_image_count > 0: description += f"Hata: `{error_image_count}` adet\n" embed = { "username": "VPS Monitor", "embeds": [ { "title": "VPS 81", "color": 16711680, # Kırmızı renk (RGB: #FF0000) "description": description, "image": {"url": image_url}, "footer": {"text": "01/08/2024"} } ] } response = requests.post(WEBHOOK_URL, json=embed) if response.status_code == 204: print("Embed başarıyla gönderildi.") else: print(f"Bir hata oluştu: {response.status_code} - {response.text}") def capture_screenshot_and_metrics(icon_path, error_image_path): screenshot_path = "screenshot.png" output_path = "output_image_with_boxes.png" error_image_path_with_boxes = "error_image_with_boxes.png" # Ekran görüntüsünü al screenshot = ImageGrab.grab() screenshot.save(screenshot_path) # Sistem metriklerini al cpu_usage, gpu_usage, ram_usage, active_windows = get_system_metrics() # Icon resimlerini say ve işaretle icon_images = count_images_on_screen(icon_path) save_image_with_boxes(icon_path, icon_images, output_path, color="red") # Hata resimlerini say ve işaretle error_images = count_images_on_screen(error_image_path) save_image_with_boxes(error_image_path, error_images, error_image_path_with_boxes, color="blue") return screenshot_path, cpu_usage, gpu_usage, ram_usage, active_windows, output_path, len(icon_images), len(error_images), error_image_path_with_boxes def main(): icon_path = "images/icon.png" error_image_path = "images/hata.png" while True: try: screenshot_path, cpu_usage, gpu_usage, ram_usage, active_windows, output_path, image_count, error_image_count, error_image_path_with_boxes = capture_screenshot_and_metrics(icon_path, error_image_path) image_url = upload_image_to_imgur(output_path) if image_url: send_embed_to_discord(cpu_usage, gpu_usage, ram_usage, active_windows, image_url, image_count, error_image_count) os.remove(screenshot_path) os.remove(output_path) os.remove(error_image_path_with_boxes) except Exception as e: print(f"Bir hata oluştu: {e}") time.sleep(8 * 60) if __name__ == "__main__": main()