diff --git a/gaming_deals_bot/__main__.py b/gaming_deals_bot/__main__.py index 93c6525..bfe21a6 100644 --- a/gaming_deals_bot/__main__.py +++ b/gaming_deals_bot/__main__.py @@ -69,6 +69,8 @@ async def main(): scheduler.start() logger.info("Bot started — scheduler running") + await bot.send_intro() + # Run initial checks immediately (after first-run population is done) await bot.check_cheapshark() await bot.check_epic_free_games() diff --git a/gaming_deals_bot/bot.py b/gaming_deals_bot/bot.py index 99a53b4..9629660 100644 --- a/gaming_deals_bot/bot.py +++ b/gaming_deals_bot/bot.py @@ -72,6 +72,12 @@ class DealsBot: total = len(deals) + len(current_free) + len(upcoming) logger.info("First run: recorded %d existing deals/games", total) + async def send_intro(self): + """Send an intro message to the Matrix room if configured.""" + if not self.config.send_intro_message: + return + await self.matrix.send_notice("The deals must flow.") + async def check_cheapshark(self): """Poll CheapShark for deals and post new ones.""" if not self._first_run_done: diff --git a/gaming_deals_bot/config.py b/gaming_deals_bot/config.py index 4c25a9e..96ceecd 100644 --- a/gaming_deals_bot/config.py +++ b/gaming_deals_bot/config.py @@ -19,6 +19,11 @@ class Config: self.min_discount_percent = int(os.environ.get("MIN_DISCOUNT_PERCENT", "50")) self.max_price_usd = float(os.environ.get("MAX_PRICE_USD", "20")) + # Intro message on startup + self.send_intro_message = os.environ.get( + "SEND_INTRO_MESSAGE", "false" + ).lower() in ("true", "1", "yes") + # Database self.database_path = os.environ.get("DATABASE_PATH", "deals.db") diff --git a/gaming_deals_bot/matrix_client.py b/gaming_deals_bot/matrix_client.py index be01e89..7d96da6 100644 --- a/gaming_deals_bot/matrix_client.py +++ b/gaming_deals_bot/matrix_client.py @@ -47,5 +47,26 @@ class MatrixDealsClient: logger.error("Matrix send error: %s", exc) return False + async def send_notice(self, text: str) -> bool: + """Send a plain m.notice (non-highlight) message to the configured room.""" + content = { + "msgtype": "m.notice", + "body": text, + } + + try: + resp = await self._client.room_send( + room_id=self.room_id, + message_type="m.room.message", + content=content, + ) + if isinstance(resp, RoomSendError): + logger.error("Failed to send notice: %s", resp.message) + return False + return True + except Exception as exc: + logger.error("Matrix send error: %s", exc) + return False + async def close(self): await self._client.close()