fix(bridge): 5 bug fixes for approval signal drop and Discord relay
- DEDUP: add conversation_id guard to prevent cross-session step_index collision - step_probe: suppress pending when projectName=default (empty window) - watchCommandsDir: add 3s polling fallback (fs.watch silent fail on Windows) - auto toggle: write chat_snapshot confirmation back to Discord - bot on_message: add message ID dedup for Gateway event replay
This commit is contained in:
11
bot.py
11
bot.py
@@ -180,6 +180,7 @@ class GravityBot(commands.Bot):
|
||||
self.session_category: discord.CategoryChannel | None = None
|
||||
self.guild: discord.Guild | None = None
|
||||
self.auto_approve_projects: set[str] = set() # projects with auto-approve enabled
|
||||
self._processed_message_ids: set[int] = set() # dedup for Gateway event replay
|
||||
self.gateway = None # Set by main.py in gateway mode
|
||||
|
||||
def _write_command(self, project: str, text: str, **kwargs):
|
||||
@@ -771,6 +772,16 @@ class GravityBot(commands.Bot):
|
||||
if message.author == self.user:
|
||||
return
|
||||
|
||||
# Dedup: Discord Gateway can deliver MESSAGE_CREATE twice on reconnection
|
||||
if message.id in self._processed_message_ids:
|
||||
return
|
||||
self._processed_message_ids.add(message.id)
|
||||
# Keep set bounded (last 200 messages)
|
||||
if len(self._processed_message_ids) > 200:
|
||||
excess = len(self._processed_message_ids) - 100
|
||||
for _ in range(excess):
|
||||
self._processed_message_ids.pop()
|
||||
|
||||
# Determine project from channel
|
||||
project = self.channel_to_project.get(message.channel.id)
|
||||
if not project:
|
||||
|
||||
Reference in New Issue
Block a user