v3.3 - Better default env var #19
@ -8,7 +8,4 @@ COPY /app/ /app/
|
||||
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
ENV DISCORD_WEBHOOK_URL="https://example.com/webhook" \
|
||||
REFRESH_TIME="30"
|
||||
|
||||
CMD ["python", "main.py"]
|
@ -17,7 +17,7 @@ try:
|
||||
DISCORD_SERVER_NAME = os.environ.get('DISCORD_SERVER_NAME', 'Shared for free')
|
||||
API_URL_SKU = os.environ.get('API_URL_SKU', 'https://api.nvidia.partners/edge/product/search?page=1&limit=100&locale=fr-fr&Manufacturer=Nvidia')
|
||||
API_URL_STOCK = os.environ.get('API_URL_STOCK', 'https://api.store.nvidia.com/partner/v1/feinventory?locale=fr-fr&skus=')
|
||||
REFRESH_TIME = int(os.environ['REFRESH_TIME'])
|
||||
REFRESH_TIME = int(os.environ.get('REFRESH_TIME', 30))
|
||||
TEST_MODE = os.environ.get('TEST_MODE', 'False').lower() == 'true'
|
||||
PRODUCT_URL = os.environ.get('PRODUCT_URL', 'https://marketplace.nvidia.com/fr-fr/consumer/graphics-cards/?locale=fr-fr&page=1&limit=12&manufacturer=NVIDIA')
|
||||
DISCORD_ROLES = os.environ.get('DISCORD_ROLES')
|
||||
@ -67,6 +67,10 @@ if match:
|
||||
else:
|
||||
wh_masked_url = "[Invalid webhook URL]"
|
||||
|
||||
# Test mode
|
||||
if TEST_MODE:
|
||||
logging.warning("🚧 Test mode is active. No real alerts will be sent.")
|
||||
|
||||
# HTTP headers
|
||||
HEADERS = {
|
||||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) "
|
||||
@ -128,6 +132,7 @@ footer = loc["footer"]
|
||||
sku_description = loc["sku_description"]
|
||||
imminent_drop = loc["imminent_drop"]
|
||||
|
||||
# Logging
|
||||
logging.info(f"GPU: {PRODUCT_NAMES}")
|
||||
logging.info(f"Discord Webhook URL: {wh_masked_url}")
|
||||
logging.info(f"Discord Role Mention: {DISCORD_ROLES}")
|
||||
|
@ -10,6 +10,7 @@ from env_config import (
|
||||
AVATAR = "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/ds_wh_pp.jpg"
|
||||
THUMBNAIL = "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/RTX5000.jpg"
|
||||
|
||||
# In stock
|
||||
def send_discord_notification(gpu_name, product_link, products_price):
|
||||
timestamp = int(time.time())
|
||||
if TEST_MODE:
|
||||
@ -45,6 +46,7 @@ def send_discord_notification(gpu_name, product_link, products_price):
|
||||
except Exception as e:
|
||||
logging.error(f"🚨 Error sending webhook: {e}")
|
||||
|
||||
# Out of stock
|
||||
def send_out_of_stock_notification(gpu_name, product_link, products_price):
|
||||
timestamp = int(time.time())
|
||||
if TEST_MODE:
|
||||
@ -76,6 +78,7 @@ def send_out_of_stock_notification(gpu_name, product_link, products_price):
|
||||
except Exception as e:
|
||||
logging.error(f"🚨 Error sending webhook: {e}")
|
||||
|
||||
# SKU change
|
||||
def send_sku_change_notification(gpu_name, old_sku, new_sku, product_link):
|
||||
timestamp = int(time.time())
|
||||
if TEST_MODE:
|
||||
|
Reference in New Issue
Block a user