feat(debate): MVP 구현 — debate_handler + 커맨드 연동 (start/stop/next/inject)
This commit is contained in:
@@ -21,6 +21,7 @@ from core.workspace import WorkspaceManager
|
||||
from core.gemini_caller import GeminiCaller, GeminiCallError
|
||||
from core.foreman import Foreman
|
||||
from handlers.nc_handler import NCHandler
|
||||
from handlers.debate_handler import DebateHandler, DEBATE_AGENTS, DEBATE_CONTROL_CH
|
||||
|
||||
logger = logging.getLogger("variet.discord")
|
||||
|
||||
@@ -282,10 +283,16 @@ async def on_command_error(ctx, error):
|
||||
@bot.event
|
||||
async def on_message(message: discord.Message):
|
||||
"""메시지 수신 — 워크스페이스 채널이면 자동 응답."""
|
||||
if message.author == bot.user or message.author.bot:
|
||||
# Debate: AG 봇 응답 감지 (봇 메시지도 처리해야 함)
|
||||
if message.author.bot and message.author != bot.user:
|
||||
if message.channel.id in DEBATE_AGENTS.values():
|
||||
await _debate_handler.on_agent_message(message)
|
||||
return
|
||||
|
||||
# ! 명령어 처리
|
||||
if message.author == bot.user:
|
||||
return
|
||||
|
||||
# ! 명령어 처리 (debate 채널 포함)
|
||||
if message.content.startswith(config.DISCORD_COMMAND_PREFIX):
|
||||
await bot.process_commands(message)
|
||||
return
|
||||
@@ -1208,17 +1215,15 @@ async def info_command(ctx: commands.Context):
|
||||
# Debate Room — 토론 채널 연동
|
||||
# ──────────────────────────────────────────────
|
||||
|
||||
DEBATE_CHANNELS = {
|
||||
"gemini": 1484156194187771905,
|
||||
"opus": 1484156521209401476,
|
||||
}
|
||||
# Debate handler 초기화
|
||||
_debate_handler = DebateHandler(bot)
|
||||
|
||||
|
||||
@bot.command(name="debate-test")
|
||||
async def debate_test(ctx: commands.Context):
|
||||
"""토론 채널 연결 테스트."""
|
||||
results = []
|
||||
for name, ch_id in DEBATE_CHANNELS.items():
|
||||
for name, ch_id in DEBATE_AGENTS.items():
|
||||
ch = bot.get_channel(ch_id)
|
||||
if ch is None:
|
||||
try:
|
||||
@@ -1240,6 +1245,39 @@ async def debate_test(ctx: commands.Context):
|
||||
await ctx.reply(embed=embed)
|
||||
|
||||
|
||||
@bot.command(name="debate-start")
|
||||
async def debate_start(ctx: commands.Context, *, topic: str = ""):
|
||||
"""토론 시작. 사용법: !debate-start 주제"""
|
||||
if not topic:
|
||||
await ctx.reply("⚠️ 주제를 입력하세요: `!debate-start 주제`")
|
||||
return
|
||||
await _debate_handler.start(ctx, topic)
|
||||
|
||||
|
||||
@bot.command(name="debate-stop")
|
||||
async def debate_stop(ctx: commands.Context):
|
||||
"""토론 중단."""
|
||||
await _debate_handler.stop(ctx)
|
||||
|
||||
|
||||
@bot.command(name="debate-next")
|
||||
async def debate_next(ctx: commands.Context):
|
||||
"""다음 턴 진행."""
|
||||
if not _debate_handler.session.active:
|
||||
await ctx.reply("진행 중인 토론이 없습니다.")
|
||||
return
|
||||
await _debate_handler._next_turn()
|
||||
|
||||
|
||||
@bot.command(name="debate-inject")
|
||||
async def debate_inject(ctx: commands.Context, *, opinion: str = ""):
|
||||
"""사용자 의견 삽입 후 다음 턴. 사용법: !debate-inject 의견"""
|
||||
if not opinion:
|
||||
await ctx.reply("⚠️ 의견을 입력하세요: `!debate-inject 의견`")
|
||||
return
|
||||
await _debate_handler.inject(ctx, opinion)
|
||||
|
||||
|
||||
async def start_bot():
|
||||
"""Discord Bot 시작."""
|
||||
token = config.DISCORD_BOT_TOKEN
|
||||
|
||||
Reference in New Issue
Block a user