Commit Graph

16 Commits

Author SHA1 Message Date
Claude Owner
1841828f7a feat(voice): per-user TTS voice selection via /목소리
Until now every TTS message was synthesized with VoiceType.가람
regardless of who spoke. This adds a user-scoped voice preference
persisted in SQLite so each member can pick their own voice and
keep it across bot restarts.

Changes
- db/schema.sql: add nullable `voice_type` column to `users`.
- src/utils/Database.ts:
  - run a PRAGMA-driven ALTER TABLE migration so existing DBs gain
    the column without dropping data.
  - add `DB.user.setVoice(guildId, userId, name, voiceType)` that
    upserts the row.
- src/classes/TTSClient.ts:
  - export `DEFAULT_VOICE` (= 가람).
  - resolve the speaking member's stored voice in `tts()` and
    thread it through `getSource()` instead of hardcoding 가람.
  - validate stored slug against `VoiceType` so stale/unknown
    values silently fall back to the default.
- src/commands/voice.ts (new):
  - `/목소리` slash command shows the user's current voice and a
    StringSelectMenu of all `VoiceType` entries (현재 + 이전 보이스
    모두). Selection writes to `users.voice_type` and confirms
    ephemerally.
  - defensively creates a guild row if `/tts channel register`
    hasn't run yet, to satisfy the ON DELETE CASCADE FK.

Deploy
Run `npm run prod` after pulling so Discord sees the new
`/목소리` command. No env or config changes required.
2026-05-26 22:50:53 +09:00
Claude Owner
2002b1cc12 docs(voice): document interrupt-latest as a design choice
VoiceSession.play() replaces the currently playing TTS on every new
message instead of queueing it. Without this comment a future reader
(or code review) is likely to file it as a missing-feature bug, but
the absence of a queue is intentional: in a many-user voice channel,
queueing causes a speaker's own message to lag far behind the chat
context. Document the policy at the call site.
2026-05-26 14:59:43 +09:00
Claude Owner
204b813ecc build: make npm run build self-sufficient
The ts-cleaner step in the build script scans dist/ and crashes with
ENOENT if the directory doesn't exist (e.g. on a fresh clone or after
git clean). Previously README told users to 'mkdir -p dist' first,
but Dockerfile and CI didn't necessarily follow that. Prepend a small
node one-liner that mkdir's dist recursively before ts-cleaner runs,
and drop the now-redundant manual step from README.
2026-05-26 14:48:30 +09:00
Claude Owner
499852b2a7 fix(tts): avoid char-by-char split when signature list is empty
SignatureClient.regex returned new RegExp("()", "g") when nameSet
was empty (server unreachable, list not yet synced). text.split() with
that regex matches every zero-width position, so 'abc' became
['a','','b','','c',''] and TTSClient sent a separate Chzzk request
per character.

Two-layer fix:
- SignatureClient.regex returns /$^/g (never-match) when names is
  empty, so split() returns the original string as a single element.
- TTSClient.getSource explicitly skips split when nameSet.size === 0
  so the intent is obvious at the call site.
2026-05-26 14:48:24 +09:00
Claude Owner
08de63b448 docs: refresh README for fixes landed in this branch
- Drop the 'known build defect' callout — tsconfig now compiles
  cleanly with rootDir + ignoreDeprecations applied.
- Add SIGNATURE_HOST to the env var table.
2026-05-26 14:42:35 +09:00
Claude Owner
acdaa4734f chore: harden logger TZ, ffmpeg lifecycle and fix package metadata
- Logger.Timestamp now formats via Intl with timeZone Asia/Seoul, so
  the timestamp is correct regardless of the container/host TZ. The
  previous setHours(+9) hack assumed the system clock was UTC.
- Transcode.mp3BufferToPcmStream now attaches error/stderr handlers
  to the ffmpeg child process and its streams, swallows EPIPE on
  early downstream close, and force-kills on spawn error so failed
  conversions can't leak processes. Log level bumped from 'quiet'
  to 'error' so real ffmpeg errors surface.
- package.json homepage/bugs/repository pointed at github.com/tkrmagid/bot.ts
  which doesn't reflect this repo. Repoint to the actual Gitea origin.
2026-05-26 14:41:29 +09:00
Claude Owner
35569ddd88 fix(handler): filter command files and guard non-command modules
Handler.ts iterated readdirSync(COMMANDS_PATH) without filtering, so
any .d.ts declaration file, .js.map source map, or non-class module
that landed in commands/ would crash startup with 'mod.default is not
a constructor'. Restrict loading to .ts/.js (excluding .d.ts and maps)
and skip modules without a default-exported constructor.
2026-05-26 14:40:29 +09:00
Claude Owner
fe10ed1bd9 feat(signature): make host configurable and add WS reconnect
- New optional env SIGNATURE_HOST overrides the hardcoded
  192.168.10.5:2967 (defaults preserved for back-compat).
- WebSocket now reconnects with exponential backoff (1s, 2s, 4s ...
  capped at 30s) on close/error. Previously a dropped signature
  server connection silently disabled signature playback until the
  bot was restarted.
2026-05-26 14:40:05 +09:00
Claude Owner
9123afc14e chore(ts): make tsconfig compatible with TypeScript 6
- Add rootDir: ./src so tsc no longer errors with TS5011 demanding it
  be set explicitly alongside outDir.
- Add ignoreDeprecations: 6.0 to silence the TS5101 baseUrl deprecation
  warning until baseUrl is removed in TS 7.
2026-05-26 14:39:07 +09:00
Claude Owner
e22cb53ccf fix(tts): correct Discord snowflake regex and getSource typo
- Mention/emoji regexes used [(0-9)]{18}; '(' and ')' inside a character
  class are literal so this matched the bracket chars themselves and
  hard-fixed the ID length to 18. Discord snowflakes are 17-20 digits
  (older 2015-2017 accounts are 17, 2024+ trend toward 19-20). Switch
  to \\d{17,20} and capture the ID for member lookup.
- Tighten emoji regex name segment from .* (greedy, eats across emojis)
  to [^:]+ so adjacent emojis no longer collapse into one match.
- Rename getSorce -> getSource.
2026-05-26 14:38:46 +09:00
Claude Owner
7b56d2e055 fix(db): correct user.update target table
stmt.user.update was issuing UPDATE guilds instead of UPDATE users,
so any DB.user.update() call would silently corrupt guild rows that
happened to share the same WHERE clause shape and never touch the
intended user row.
2026-05-26 14:38:09 +09:00
Claude Owner
9288127561 docs: rewrite README with project overview
코드베이스 분석 결과를 반영해 README를 placeholder에서 실사용 가능한 문서로 개편.
주요 기능, 슬래시/prefix 명령어, 기술 스택, 디렉터리 구조, 환경변수 표,
실행/Docker 절차, 동작 흐름을 정리하고, 현재 tsconfig 결함으로 인한
빌드 실패(TS5101/TS5011)와 해결 방법을 명시.
2026-05-26 14:28:50 +09:00
Claude Owner
7876283e08 Merge upstream tts_bot main 2026-05-26 14:18:44 +09:00
ejclaw
6bfef454b4 init tts_bot workspace 2026-05-26 14:16:38 +09:00
d6b36c43c2 기존 2026-05-26 14:15:09 +09:00
55d402f606 Initial commit 2026-05-26 14:12:31 +09:00