fix(bot): remove lingering bridge dependency triggering AttributeError on pending relay
This commit is contained in:
52
bot.py
52
bot.py
@@ -555,54 +555,6 @@ class GravityBot(commands.Bot):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def _send_approval_request(
|
|
||||||
self, channel: discord.TextChannel, request: ApprovalRequest
|
|
||||||
):
|
|
||||||
# Read buttons array from pending file (if present)
|
|
||||||
buttons = None
|
|
||||||
pending_file = self.bridge.pending_dir / f"{request.request_id}.json"
|
|
||||||
if pending_file.exists():
|
|
||||||
try:
|
|
||||||
pending_data = json.loads(
|
|
||||||
pending_file.read_text(encoding="utf-8-sig")
|
|
||||||
)
|
|
||||||
buttons = pending_data.get("buttons")
|
|
||||||
except (json.JSONDecodeError, OSError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Build embed description
|
|
||||||
desc_parts = [f"**명령어:**\n```\n{request.command[:1000]}\n```"]
|
|
||||||
if buttons and len(buttons) > 1:
|
|
||||||
# Multi-choice: show all options in description
|
|
||||||
btn_names = [b.get("text", "?") for b in buttons]
|
|
||||||
desc_parts.append(f"**선택지:** {' / '.join(btn_names)}")
|
|
||||||
if request.description:
|
|
||||||
desc_parts.append(request.description[:500])
|
|
||||||
|
|
||||||
embed = discord.Embed(
|
|
||||||
title="⚠️ 승인 요청",
|
|
||||||
description="\n".join(desc_parts),
|
|
||||||
color=discord.Color.orange(),
|
|
||||||
timestamp=datetime.now(timezone.utc),
|
|
||||||
)
|
|
||||||
embed.set_footer(text=f"ID: {request.request_id}")
|
|
||||||
|
|
||||||
view = ApprovalView(self.bridge, request, buttons=buttons, hub=self.hub)
|
|
||||||
msg = await channel.send(embed=embed, view=view)
|
|
||||||
|
|
||||||
if pending_file.exists():
|
|
||||||
try:
|
|
||||||
data = json.loads(pending_file.read_text(encoding="utf-8-sig"))
|
|
||||||
data["discord_message_id"] = msg.id
|
|
||||||
pending_file.write_text(
|
|
||||||
json.dumps(data, ensure_ascii=False, indent=2), encoding="utf-8"
|
|
||||||
)
|
|
||||||
except (json.JSONDecodeError, OSError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
logger.info(f"Sent approval request: {request.request_id[:12]}")
|
|
||||||
self._cap_dict(self._approval_messages)
|
|
||||||
self._approval_messages[request.request_id] = msg.id # FIX #4: Track msg_id for auto_resolved lookup
|
|
||||||
|
|
||||||
# ─── Discord → IDE Text Relay + Multi-PC UX ───────────────────────────
|
# ─── Discord → IDE Text Relay + Multi-PC UX ───────────────────────────
|
||||||
|
|
||||||
@@ -787,7 +739,7 @@ class GravityBot(commands.Bot):
|
|||||||
)
|
)
|
||||||
embed.set_footer(text=f"ID: {request_id}")
|
embed.set_footer(text=f"ID: {request_id}")
|
||||||
|
|
||||||
view = ApprovalView(self.bridge, request, buttons=buttons, hub=self.hub)
|
view = ApprovalView(request, buttons=buttons, hub=self.hub)
|
||||||
msg = await channel.send(embed=embed, view=view)
|
msg = await channel.send(embed=embed, view=view)
|
||||||
|
|
||||||
self._cap_dict(self._sent_approval_ids)
|
self._cap_dict(self._sent_approval_ids)
|
||||||
@@ -906,7 +858,7 @@ class GravityBot(commands.Bot):
|
|||||||
async def _hub_on_brain_event(self, project: str, data: dict):
|
async def _hub_on_brain_event(self, project: str, data: dict):
|
||||||
"""Handle brain event from Hub (Extension->Hub->Bot->Discord)."""
|
"""Handle brain event from Hub (Extension->Hub->Bot->Discord)."""
|
||||||
try:
|
try:
|
||||||
from watcher import BrainEvent, EventType
|
from models import BrainEvent, EventType
|
||||||
event = BrainEvent(
|
event = BrainEvent(
|
||||||
event_type=EventType(data.get("event_type", "file_changed")),
|
event_type=EventType(data.get("event_type", "file_changed")),
|
||||||
conversation_id=data.get("conversation_id", ""),
|
conversation_id=data.get("conversation_id", ""),
|
||||||
|
|||||||
Reference in New Issue
Block a user