fix(collector): 기능 누락 3건 수정 — Discord 명령어/채팅/등록 중계
Gap 1: Discord→Extension 명령어 깨짐 - bot.py: _write_command() 래퍼 — gateway.push_command()도 호출 - main.py: bot.gateway 연결 - 슬래시 명령어 + on_message 모두 _write_command 사용 Gap 2: Chat snapshot 미전달 - collector.py: _forward_chat_snapshots_loop 추가 Gap 3: Session registration 미전달 - collector.py: _forward_registrations_loop 추가
This commit is contained in:
24
bot.py
24
bot.py
@@ -180,6 +180,18 @@ 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.gateway = None # Set by main.py in gateway mode
|
||||
|
||||
def _write_command(self, project: str, text: str, **kwargs):
|
||||
"""Write command to bridge AND push to gateway (if gateway mode)."""
|
||||
self.bridge.write_command(project, text, **kwargs)
|
||||
if self.gateway:
|
||||
import time
|
||||
self.gateway.push_command(project, {
|
||||
"id": str(int(time.time() * 1000)),
|
||||
"text": text,
|
||||
"project_name": kwargs.get('project_name', project),
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def _make_channel_name(project_name: str) -> str:
|
||||
@@ -202,7 +214,7 @@ class GravityBot(commands.Bot):
|
||||
if not project:
|
||||
await interaction.response.send_message("⚠️ 프로젝트 채널이 아닙니다.", ephemeral=True)
|
||||
return
|
||||
self.bridge.write_command(project, "!stop", project_name=project)
|
||||
self._write_command(project, "!stop", project_name=project)
|
||||
await interaction.response.send_message(
|
||||
embed=discord.Embed(
|
||||
title="⏹️ AI 작업 중지",
|
||||
@@ -224,7 +236,7 @@ class GravityBot(commands.Bot):
|
||||
else:
|
||||
self.auto_approve_projects.add(project)
|
||||
enabled = True
|
||||
self.bridge.write_command(project, f"!auto {'on' if enabled else 'off'}", project_name=project)
|
||||
self._write_command(project, f"!auto {'on' if enabled else 'off'}", project_name=project)
|
||||
emoji = "🟢" if enabled else "🔴"
|
||||
await interaction.response.send_message(
|
||||
embed=discord.Embed(
|
||||
@@ -240,7 +252,7 @@ class GravityBot(commands.Bot):
|
||||
if not project:
|
||||
await interaction.response.send_message("⚠️ 프로젝트 채널이 아닙니다.", ephemeral=True)
|
||||
return
|
||||
self.bridge.write_command(project, message, project_name=project)
|
||||
self._write_command(project, message, project_name=project)
|
||||
await interaction.response.send_message(
|
||||
embed=discord.Embed(
|
||||
description=f"📨 → **{project}** IDE에 전달됨\n`{message[:100]}`",
|
||||
@@ -754,7 +766,7 @@ class GravityBot(commands.Bot):
|
||||
|
||||
# Special command: !stop — cancel AI work
|
||||
if text == "!stop":
|
||||
self.bridge.write_command(project, "!stop", project_name=project)
|
||||
self._write_command(project, "!stop", project_name=project)
|
||||
embed = discord.Embed(
|
||||
title="⏹️ AI 작업 중지",
|
||||
description=f"프로젝트: **{project}**\n중지 요청을 Extension에 전달했습니다.",
|
||||
@@ -772,7 +784,7 @@ class GravityBot(commands.Bot):
|
||||
else:
|
||||
self.auto_approve_projects.add(project)
|
||||
enabled = True
|
||||
self.bridge.write_command(project, f"!auto {'on' if enabled else 'off'}", project_name=project)
|
||||
self._write_command(project, f"!auto {'on' if enabled else 'off'}", project_name=project)
|
||||
emoji = "🟢" if enabled else "🔴"
|
||||
mode = "자동 승인" if enabled else "수동 승인"
|
||||
embed = discord.Embed(
|
||||
@@ -786,7 +798,7 @@ class GravityBot(commands.Bot):
|
||||
|
||||
# General text relay — routed by project
|
||||
if text:
|
||||
self.bridge.write_command(project, text, project_name=project)
|
||||
self._write_command(project, text, project_name=project)
|
||||
await message.add_reaction("📨")
|
||||
embed = discord.Embed(
|
||||
description=f"📨 → **{project}** IDE에 전달됨\n`{text[:100]}`",
|
||||
|
||||
Reference in New Issue
Block a user