diff --git a/README.md b/README.md index aa82944..49aaee9 100644 --- a/README.md +++ b/README.md @@ -245,8 +245,10 @@ Claude 두뇌 → GPU TTS를 돌려 응답 wav를 돌려주고 봇이 채널에 - **화이트/블랙리스트** — 팝업에서 서버의 유저/역할을 검색해 추가/제거. 화이트리스트가 있으면 그 대상만 청취(비어있으면 전체), 블랙리스트는 제외. 봇이 발화자 SSRC→유저/역할로 필터 (`dave/filter.mjs`의 `isAllowed`). -- **대화 카드** — 들음 / 생각(감정 톤 계획) / 답변 3분할, 발화자(🗣) 표시, 단계별·총 소요시간. -- **로그 패널** — 하단 고정 VSCode 터미널식, 열고닫기, 시작부터 기록. 텍스트/레벨 검색, +- **대화 카드 + 로그 검색** — 들음 / 생각(감정 톤 계획) / 답변 3분할, 발화자(🗣)·서버/채널(🔊) + 표시, 단계별·총 소요시간. 대화 로그는 **시간·유저(발화자)·서버·채널·내용**으로 필터한다 + (턴에 speaker/guild/channel 메타데이터를 실어 봇이 X-User/Guild/Channel-Name 헤더로 보고). +- **이벤트 로그 패널** — 하단 고정 VSCode 터미널식, 열고닫기, 시작부터 기록. 텍스트/레벨 검색, 전체·라인별 삭제/수정(`/api/logs/{clear,delete,edit}`). ### 대시보드 ↔ 봇 제어 채널 diff --git a/dave/bot.mjs b/dave/bot.mjs index 875d1ee..a0fad90 100644 --- a/dave/bot.mjs +++ b/dave/bot.mjs @@ -123,9 +123,15 @@ async function handleUtterance(userId, pcm) { } catch {} let resp; try { + const guildName = (currentGuildId && client.guilds.cache.get(currentGuildId)?.name) || ''; resp = await fetch(VOICE_ENDPOINT, { method: 'POST', - headers: { 'Content-Type': 'audio/wav', 'X-User-Name': encodeURIComponent(speaker) }, + headers: { + 'Content-Type': 'audio/wav', + 'X-User-Name': encodeURIComponent(speaker), + 'X-Guild-Name': encodeURIComponent(guildName), + 'X-Channel-Name': encodeURIComponent(currentChannelName || ''), + }, body: wav, }); } catch (e) { diff --git a/wsai/dashboard.py b/wsai/dashboard.py index c70c9ee..7fef884 100644 --- a/wsai/dashboard.py +++ b/wsai/dashboard.py @@ -135,8 +135,10 @@ def _make_handler(dash: "Dashboard"): "application/json; charset=utf-8") return speaker = urllib.parse.unquote(self.headers.get("X-User-Name", "") or "") + guild = urllib.parse.unquote(self.headers.get("X-Guild-Name", "") or "") + channel = urllib.parse.unquote(self.headers.get("X-Channel-Name", "") or "") try: - res = dash.voice_turn(raw, speaker=speaker) + res = dash.voice_turn(raw, speaker=speaker, guild=guild, channel=channel) except Exception as exc: # noqa: BLE001 log.exception("voice-turn failed") self._send(500, json.dumps({"ok": False, "error": f"{type(exc).__name__}: {exc}"}, @@ -395,7 +397,8 @@ class Dashboard: if self.tts is not None: self._submit(self.tts._ensure()) - def voice_turn(self, audio_bytes: bytes, speaker: str = "") -> dict: + def voice_turn(self, audio_bytes: bytes, speaker: str = "", + guild: str = "", channel: str = "") -> dict: """One Discord voice turn: decode the uploaded utterance, recognise it on the GPU, think of a reply (Claude brain if wired, else echo), synthesise it on the GPU, and return {heard, reply, wav} where wav is the @@ -416,6 +419,7 @@ class Dashboard: turn = self.monitor.turn(source="discord") if speaker: turn.speaker = speaker # who spoke (for the "누가 말했는지" log) + turn.guild, turn.channel = guild, channel # for 서버별/채널별 필터 t0 = time.monotonic() try: subprocess.run( @@ -629,6 +633,14 @@ PAGE = r""" border-radius:999px;padding:3px 10px;font-size:12px} .part.spk{border-color:#1f5236;color:#9ff0bd} .speaker{color:var(--muted);font-size:11.5px} + /* 대화 로그 검색 필터 (시간·유저·서버·채널·내용) */ + .tfilter{display:flex;gap:8px;align-items:center;flex-wrap:wrap;background:var(--panel); + border:1px solid var(--line);border-radius:12px;padding:8px 12px;margin:0 0 12px} + .tfilter input,.tfilter select{background:var(--panel2);border:1px solid var(--line);color:var(--fg); + border-radius:8px;padding:6px 9px;font-size:12.5px} + .tfilter input{width:118px} + .tf-label{color:var(--muted);font-size:12px;font-weight:600} + .tf-count{color:var(--muted);font-size:11.5px;margin-left:auto} /* Modal / popup (reused by 프롬프트, 화이트/블랙리스트 …) */ .modal{position:fixed;inset:0;z-index:20;background:rgba(4,7,11,.66); display:flex;align-items:center;justify-content:center;padding:20px} @@ -736,6 +748,22 @@ PAGE = r"""
+