From 8ef909c33da2f0036ac16b5ca1ef53feece4fba1 Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Sun, 17 Mar 2024 16:15:59 +0000 Subject: [PATCH] Properly allow configuring screenshot proxy --- src/cogs/screenshot.py | 6 ++++-- src/conf.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cogs/screenshot.py b/src/cogs/screenshot.py index 4b3ca7c..0f28b24 100644 --- a/src/cogs/screenshot.py +++ b/src/cogs/screenshot.py @@ -16,6 +16,8 @@ from selenium import webdriver from selenium.webdriver.chrome.options import Options as ChromeOptions from selenium.webdriver.chrome.service import Service as ChromeService +from conf import CONFIG + class ScreenshotCog(commands.Cog): def __init__(self, bot: commands.Bot): @@ -107,8 +109,8 @@ class ScreenshotCog(commands.Cog): start_init = time.time() try: options = copy.copy(self.chrome_options) - if use_proxy: - options.add_argument("--proxy-server=http://127.0.0.1:8888") + if use_proxy and (server := CONFIG["screenshot"].get("proxy")): + options.add_argument("--proxy-server=" + server) service = await asyncio.to_thread(ChromeService) driver: webdriver.Chrome = await asyncio.to_thread( webdriver.Chrome, diff --git a/src/conf.py b/src/conf.py index 88bd862..41ee4c1 100644 --- a/src/conf.py +++ b/src/conf.py @@ -28,6 +28,7 @@ try: CONFIG.setdefault("jimmy", {}) CONFIG.setdefault("ollama", {}) CONFIG.setdefault("rss", {"meta": {"channel": None}}) + CONFIG.setdefault("screenshot", {}) CONFIG.setdefault( "server", {