Add dedicated channel for startup announcements

Add STARTUP_ANNOUNCEMENT_CHANNEL_ID to control where startup announcements are sent.

Changes:
- New config: STARTUP_ANNOUNCEMENT_CHANNEL_ID
- Announcements sent only to specified channel
- Falls back to first CHANNEL_ID if not set
- Prevents announcement spam in all stock update channels

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Michael Simard
2025-12-03 22:34:00 -06:00
parent 388430780d
commit 65fab3ee35
4 changed files with 27 additions and 8 deletions

30
bot.py
View File

@@ -104,7 +104,7 @@ class StockBot(commands.Bot):
await self.send_stock_update(self.primary_ticker, channel_id)
async def send_startup_announcement(self):
"""Send startup announcement to configured channels."""
"""Send startup announcement to configured announcement channel."""
embed = discord.Embed(
title="🤖 Bot Update",
description=Config.STARTUP_ANNOUNCEMENT,
@@ -112,13 +112,27 @@ class StockBot(commands.Bot):
timestamp=datetime.now(pytz.timezone('America/New_York'))
)
for channel_id in self.target_channel_ids:
channel = self.get_channel(channel_id)
if channel:
await channel.send(embed=embed)
logger.info(f"Sent startup announcement to channel {channel_id}")
else:
logger.error(f"Could not send announcement to channel {channel_id}")
# Use dedicated announcement channel if configured, otherwise use first target channel
announcement_channel_id = Config.STARTUP_ANNOUNCEMENT_CHANNEL_ID
if announcement_channel_id:
try:
channel_id = int(announcement_channel_id)
except ValueError:
logger.error(f"Invalid STARTUP_ANNOUNCEMENT_CHANNEL_ID: {announcement_channel_id}")
return
else:
channel_id = self.target_channel_ids[0] if self.target_channel_ids else None
if not channel_id:
logger.error("No channel configured for startup announcement")
return
channel = self.get_channel(channel_id)
if channel:
await channel.send(embed=embed)
logger.info(f"Sent startup announcement to channel {channel_id}")
else:
logger.error(f"Could not find announcement channel {channel_id}")
async def send_stock_update(self, ticker: str, channel_id: int):
"""