Add multi-currency pricing (USD, CAD, EUR, GBP) for deal posts
Fetches live exchange rates from the Frankfurter API (ECB data, free, no API key) and displays converted prices alongside USD in every deal message. Rates are cached in memory and auto-refreshed hourly. https://claude.ai/code/session_01LPpSZFfyh6vdV5HGFWjoQX
This commit is contained in:
@@ -7,6 +7,7 @@ import httpx
|
||||
|
||||
from .cheapshark import CheapSharkDeal, fetch_deals
|
||||
from .config import Config
|
||||
from .currency import refresh_rates
|
||||
from .database import Database
|
||||
from .epic import EpicFreeGame, fetch_free_games
|
||||
from .formatter import format_deal, format_epic_free, format_epic_upcoming
|
||||
@@ -30,9 +31,12 @@ class DealsBot:
|
||||
self._first_run_done = False
|
||||
|
||||
async def start(self):
|
||||
"""Initialize database and run first-run population."""
|
||||
"""Initialize database, fetch exchange rates, and run first-run population."""
|
||||
await self.db.connect()
|
||||
|
||||
# Pre-fetch exchange rates so the first deal post has conversions
|
||||
await refresh_rates(self._http)
|
||||
|
||||
first_run = await self.db.get_config("first_run_done")
|
||||
if first_run != "true":
|
||||
logger.info("First run detected — populating database without posting")
|
||||
|
||||
Reference in New Issue
Block a user