feat(bot): userbot (selfbot) mode — voice conversation on one user account (stage 1)
A user account is the only kind Discord lets Go Live, so add a userbot run mode: when DISCORD_BOT_TOKEN is absent but DISCORD_SELFBOT_TOKEN is set, the app runs as a userbot instead of the normal slash-command bot. Stage 1 (conversation): log in with discord.js-selfbot-v13, auto-join DISCORD_VOICE_CHANNEL_ID on startup (or "!자비스 join" when unset), listen via the selfbot VoiceReceiver (pcm), transcribe+reply through the bridge, and speak the reply back with playAudio. Shared PCM/WAV helpers extracted to audio.ts. run-bot.sh now starts in either userbot or normal mode. Go-Live broadcast + broadcast-coupled routing land in stage 2 on the same voice connection. ToS note: selfbots violate Discord ToS; burner account only. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -7,11 +7,18 @@
|
||||
set -e
|
||||
cd /app/bot
|
||||
|
||||
# The bot needs all three to log in AND register slash commands. If any is
|
||||
# missing, wait instead of crash-looping (config.ts throws on a missing var).
|
||||
if [ -z "${DISCORD_BOT_TOKEN:-}" ] || [ -z "${DISCORD_APP_ID:-}" ] || [ -z "${DISCORD_GUILD_ID:-}" ]; then
|
||||
echo "[bot] DISCORD_BOT_TOKEN/DISCORD_APP_ID/DISCORD_GUILD_ID 중 일부 미설정 — 봇 대기 중."
|
||||
echo "[bot] .env에 셋 다 넣고 'docker compose up -d' 하면 시작됩니다."
|
||||
# Two run modes, both needing DISCORD_GUILD_ID:
|
||||
# userbot : DISCORD_SELFBOT_TOKEN set (voice + Go-Live on one user account)
|
||||
# normal : DISCORD_BOT_TOKEN + DISCORD_APP_ID set (slash commands)
|
||||
# If neither is usable yet, wait instead of crash-looping so the rest of the
|
||||
# stack (desktop, bridge, ollama) still runs.
|
||||
USERBOT_OK=0; NORMAL_OK=0
|
||||
[ -n "${DISCORD_GUILD_ID:-}" ] && [ -n "${DISCORD_SELFBOT_TOKEN:-}" ] && USERBOT_OK=1
|
||||
[ -n "${DISCORD_GUILD_ID:-}" ] && [ -n "${DISCORD_BOT_TOKEN:-}" ] && [ -n "${DISCORD_APP_ID:-}" ] && NORMAL_OK=1
|
||||
if [ "$USERBOT_OK" = 0 ] && [ "$NORMAL_OK" = 0 ]; then
|
||||
echo "[bot] Discord 자격증명 미설정 — 봇 대기 중."
|
||||
echo "[bot] 유저봇: DISCORD_GUILD_ID + DISCORD_SELFBOT_TOKEN, 또는"
|
||||
echo "[bot] 일반봇: DISCORD_GUILD_ID + DISCORD_BOT_TOKEN + DISCORD_APP_ID 를 .env에 넣고 're-up'."
|
||||
echo "[bot] (그동안 VNC 데스크톱 / 브릿지 / Ollama 는 정상 동작합니다.)"
|
||||
exec sleep infinity
|
||||
fi
|
||||
@@ -21,5 +28,9 @@ for i in $(seq 1 60); do
|
||||
curl -fsS "$BRIDGE/health" >/dev/null 2>&1 && break
|
||||
sleep 1
|
||||
done
|
||||
bun run register || echo "[bot] slash command registration failed (continuing)"
|
||||
# Slash-command registration only applies to normal-bot mode (index.ts runs the
|
||||
# normal bot whenever DISCORD_BOT_TOKEN is set; userbot mode has no slash cmds).
|
||||
if [ "$NORMAL_OK" = 1 ]; then
|
||||
bun run register || echo "[bot] slash command registration failed (continuing)"
|
||||
fi
|
||||
exec bun run start
|
||||
|
||||
Reference in New Issue
Block a user