Add gaming deals Matrix bot
Implements a Matrix bot that posts PC gaming deals and free game alerts: - CheapShark API integration (Steam, GOG, Humble, GMG) polled every 2 hours - Epic Games Store free games detection polled daily - IsThereAnyDeal historical low price flagging (optional) - SQLite deduplication with 30-day pruning - First-run population (records existing deals without posting) - Matrix-flavored HTML + plain text fallback messages - Dockerfile for containerized deployment https://claude.ai/code/session_01LPpSZFfyh6vdV5HGFWjoQX
This commit is contained in:
30
gaming_deals_bot/config.py
Normal file
30
gaming_deals_bot/config.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
|
||||
|
||||
class Config:
|
||||
"""Bot configuration loaded from environment variables."""
|
||||
|
||||
def __init__(self):
|
||||
# Matrix settings
|
||||
self.matrix_homeserver_url = self._require("MATRIX_HOMESERVER_URL")
|
||||
self.matrix_bot_user_id = self._require("MATRIX_BOT_USER_ID")
|
||||
self.matrix_bot_access_token = self._require("MATRIX_BOT_ACCESS_TOKEN")
|
||||
self.matrix_deals_room_id = self._require("MATRIX_DEALS_ROOM_ID")
|
||||
|
||||
# ITAD API key (optional — historical low checks disabled without it)
|
||||
self.itad_api_key = os.environ.get("ITAD_API_KEY", "")
|
||||
|
||||
# Deal filtering
|
||||
self.min_deal_rating = int(os.environ.get("MIN_DEAL_RATING", "80"))
|
||||
self.min_discount_percent = int(os.environ.get("MIN_DISCOUNT_PERCENT", "50"))
|
||||
self.max_price_usd = float(os.environ.get("MAX_PRICE_USD", "20"))
|
||||
|
||||
# Database
|
||||
self.database_path = os.environ.get("DATABASE_PATH", "deals.db")
|
||||
|
||||
@staticmethod
|
||||
def _require(name: str) -> str:
|
||||
value = os.environ.get(name)
|
||||
if not value:
|
||||
raise ValueError(f"Required environment variable {name} is not set")
|
||||
return value
|
||||
Reference in New Issue
Block a user