fix: add channel failure logging to diagnose Discord notification delivery issue
This commit is contained in:
32
bot.py
32
bot.py
@@ -365,6 +365,10 @@ class GravityBot(commands.Bot):
|
|||||||
if project_name in self.project_channels:
|
if project_name in self.project_channels:
|
||||||
return self.project_channels[project_name]
|
return self.project_channels[project_name]
|
||||||
|
|
||||||
|
if not self.session_category:
|
||||||
|
logger.error(f"[CHANNEL] session_category is None — cannot get channel for project={project_name}")
|
||||||
|
return None
|
||||||
|
|
||||||
channel_name = self._make_channel_name(project_name)
|
channel_name = self._make_channel_name(project_name)
|
||||||
|
|
||||||
# 1. Check guild channel cache (NO API call — instant)
|
# 1. Check guild channel cache (NO API call — instant)
|
||||||
@@ -405,6 +409,9 @@ class GravityBot(commands.Bot):
|
|||||||
except discord.errors.Forbidden:
|
except discord.errors.Forbidden:
|
||||||
logger.error(f"No permission to create channel: {channel_name}")
|
logger.error(f"No permission to create channel: {channel_name}")
|
||||||
return None
|
return None
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"[CHANNEL] Failed to create channel #{channel_name}: {e}")
|
||||||
|
return None
|
||||||
|
|
||||||
def _resolve_project(self, conversation_id: str) -> str:
|
def _resolve_project(self, conversation_id: str) -> str:
|
||||||
"""Get project name for a conversation. Falls back to default."""
|
"""Get project name for a conversation. Falls back to default."""
|
||||||
@@ -619,13 +626,18 @@ class GravityBot(commands.Bot):
|
|||||||
# Show compact auto-approved embed in Discord
|
# Show compact auto-approved embed in Discord
|
||||||
channel = await self._get_channel(project)
|
channel = await self._get_channel(project)
|
||||||
if channel:
|
if channel:
|
||||||
embed = discord.Embed(
|
try:
|
||||||
title="🤖 자동 승인됨",
|
embed = discord.Embed(
|
||||||
description=f"```\n{req.command[:500]}\n```",
|
title="🤖 자동 승인됨",
|
||||||
color=discord.Color.green(),
|
description=f"```\n{req.command[:500]}\n```",
|
||||||
)
|
color=discord.Color.green(),
|
||||||
embed.set_footer(text=f"auto-approve | {req.request_id[:12]}")
|
)
|
||||||
await channel.send(embed=embed)
|
embed.set_footer(text=f"auto-approve | {req.request_id[:12]}")
|
||||||
|
await channel.send(embed=embed)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"[AUTO-APPROVE] Discord send failed for {project}: {e}")
|
||||||
|
else:
|
||||||
|
logger.warning(f"[AUTO-APPROVE] No Discord channel for project={project} — notification skipped")
|
||||||
logger.info(f"Auto-approved: {req.request_id[:12]} project={project} btn_idx={approve_btn_index}")
|
logger.info(f"Auto-approved: {req.request_id[:12]} project={project} btn_idx={approve_btn_index}")
|
||||||
phase1_processed += 1
|
phase1_processed += 1
|
||||||
continue
|
continue
|
||||||
@@ -655,6 +667,8 @@ class GravityBot(commands.Bot):
|
|||||||
self._sent_commands[req.request_id] = req.command
|
self._sent_commands[req.request_id] = req.command
|
||||||
await self._send_approval_request(channel, req)
|
await self._send_approval_request(channel, req)
|
||||||
phase1_processed += 1
|
phase1_processed += 1
|
||||||
|
else:
|
||||||
|
logger.warning(f"[APPROVAL] No Discord channel for project={project} — approval request skipped (rid={req.request_id[:12]})")
|
||||||
|
|
||||||
# ── Single-pass: handle auto_resolved, expired, and MERGE in one glob ──
|
# ── Single-pass: handle auto_resolved, expired, and MERGE in one glob ──
|
||||||
phase2_processed = 0
|
phase2_processed = 0
|
||||||
@@ -894,7 +908,9 @@ class GravityBot(commands.Bot):
|
|||||||
|
|
||||||
if content or attached_files:
|
if content or attached_files:
|
||||||
channel = await self._get_channel(project)
|
channel = await self._get_channel(project)
|
||||||
if channel:
|
if not channel:
|
||||||
|
logger.warning(f"[SNAPSHOT] No Discord channel for project={project} — snapshot skipped (len={len(content)})")
|
||||||
|
elif channel:
|
||||||
import io
|
import io
|
||||||
|
|
||||||
# ── Send attached files (from Extension's writeChatSnapshotWithFiles) ──
|
# ── Send attached files (from Extension's writeChatSnapshotWithFiles) ──
|
||||||
|
|||||||
Reference in New Issue
Block a user