v1.3.4: 슬래시 명령 무응답 고침 · 녹음 중 봇 상태 메시지
- 원인: 그 서버를 지켜보는 앱이 없으면 discord-source 가 명령을 그냥 무시 → 디스코드 "애플리케이션이 응답하지 않았어요"
→ 1.5초 기다린 뒤(옛 v1.1.0 PC 가 먼저 받았으면 '이미 응답함'으로 빠짐) 이유를 답한다:
앱 없음 / 내 앱이 다른 서버를 녹음 대상으로 정함 / 내 앱이 아직 연결 중. 서버 로그에 남김
- 앱: 지켜보던 중 권한 재확인으로 watch_denied 를 받으면 1분 뒤 다시 지켜보기 요청 (명령 · 음성 상태가 영영 끊기지 않게)
- 상태 메시지: 봇이 어느 서버에서든 음성채널에 있으면 dnd + "🔴 녹음 중", 아니면 online + "🎙️ 대기 중 · /녹음시작"
(겜녹이 봇은 사이트 서버, 다른 봇 모드는 LocalGateway). 테스트 봇으로 실제 디스코드가 형식을 받는 것 확인
- 테스트: 앱 41 · 서버 16 통과
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
- 설계·계획: [`docs/gemnoki-project-plan.pdf`](docs/gemnoki-project-plan.pdf), 개발 구조·인터페이스: [`docs/dev/ARCHITECTURE.md`](docs/dev/ARCHITECTURE.md)
|
||||
- 범인찾기 · 리플레이 동기화 계획서 v1.2 (결정 반영): [`docs/culprit-finder-plan.pdf`](docs/culprit-finder-plan.pdf) · 원본 · 비용 계산 · 프롬프트 초안: `docs/report/culprit/` (실제로 쓰는 프롬프트는 `site/server/prompt/`)
|
||||
- **제작 완료 보고서 (M0~M8)**: [`docs/gemnoki-final-report.pdf`](docs/gemnoki-final-report.pdf) · 단계별 테스트 기록: [`docs/dev/test-results.md`](docs/dev/test-results.md)
|
||||
- Windows 실행 파일: Gitea 릴리스 [v1.3.3](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.3.3) (`GameVoiceRecorder-1.3.3-win-x64.zip` 권장, 단일 파일 `GameVoiceRecorder-1.3.3-portable.exe`) · 처음 버전 [v1.0.0](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.0.0)
|
||||
- Windows 실행 파일: Gitea 릴리스 [v1.3.4](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.3.4) (`GameVoiceRecorder-1.3.4-win-x64.zip` 권장, 단일 파일 `GameVoiceRecorder-1.3.4-portable.exe`) · 처음 버전 [v1.0.0](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.0.0)
|
||||
|
||||
## 로그인 · 관리자 (v1.2.0~)
|
||||
|
||||
@@ -19,6 +19,11 @@
|
||||
- 앱은 시작할 때와 10분마다 등록 여부를 다시 확인한다. 등록이 해제되면 바로 잠그고 봇 · 녹음 · 사이트 연결을 멈춘다. 사이트 서버에 못 붙으면 마지막 확인 뒤 3일까지는 그대로 쓴다.
|
||||
- 서버 쪽: `site/server/src/app-auth.ts` (`/auth/app/*`, `/app/me`, `/app/admin/users`), 앱 쪽: `app/src/core/auth.ts`, 권한 목록: `app/src/core/roles.ts`. 로그인 E2E: `app/scripts/login-e2e.mts`.
|
||||
|
||||
## v1.3.4 바뀐 점
|
||||
|
||||
- **슬래시 명령 응답**: 그 디스코드 서버를 지켜보는 겜녹이 앱이 없으면 사이트 서버가 명령을 무시해서 디스코드에 "애플리케이션이 응답하지 않았어요"만 떴다 (봇 토큰을 직접 쓰는 옛 v1.1.0 PC 와 겹치지 않게 넣은 동작). 이제 1.5초 기다렸다가 아무도 받지 않았으면 이유를 답한다: 앱이 꺼져 있음 / 내 앱이 다른 서버를 녹음 대상으로 정해 둠 / 아직 연결 중. 앱은 서버가 권한을 다시 확인하다 지켜보기를 끊으면 1분 뒤 다시 요청한다
|
||||
- **봇 상태 메시지**: 녹음 중(봇이 어느 서버에서든 음성채널에 있음)이면 빨간 상태(다른 용무 중) + "🔴 녹음 중", 아니면 "🎙️ 대기 중 · /녹음시작". 겜녹이 봇은 사이트 서버가, 다른 봇 모드는 앱이 바꾼다. 봇 하나가 여러 서버에 들어가 있어서 채널 이름은 넣지 않는다
|
||||
|
||||
## v1.3.3 바뀐 점
|
||||
|
||||
- **따라갈 사람 목록**: 녹음할 서버의 멤버가 모두 나온다. 내 계정이 맨 위, 그다음 관리자(최고 관리자 포함), 나머지는 이름순. 예전에는 봇이 서버를 지켜보기 전에 목록을 요청하면 사이트 서버가 거절했고 앱이 그 오류를 숨겨 "선택 안 함"만 보였다. 이제 가입한 서버면 바로 받고, 실패하면 오류와 다시 불러오기 버튼을 보여 준다. 녹음할 서버를 바꾸면 봇이 새 서버를 바로 지켜본다. 서버: `GET /app/admins`
|
||||
@@ -71,7 +76,7 @@
|
||||
| M6 단어사전 · UI/UX | 핫워드·교정 사전, 사이트 교정 반영, 테마·애니메이션·효과음 | ✅ 완료 ([사전 효과](docs/dev/test-results.md)) |
|
||||
| M7 실사용 테스트 | 통합 테스트, 성능·안정화 | ✅ 완료 (GPU 실음성: CER 3.6%, 지연 1.05초 · [기록](docs/dev/test-results.md)) |
|
||||
| M8 파인튜닝 | 교정 데이터 + 합성 음성 LoRA 학습, 오류율 비교 후 교체 | ✅ 완료 (GPU 시험 학습: CER 4.8% → 1.8%) |
|
||||
| 범인찾기 (v1.3.x) | AI(Claude Opus 5.5 high) 10명 평점 · 팀별 범인 · 근거, 기록 점수(OP.GG OP스코어 계산법) · 10/15분 라인전(LOL.PS 정의) | ✅ 완료 (실제 Claude E2E, 사이트 배포, [v1.3.3](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.3.3) · 리플레이 동기화는 Windows 실기 확인 뒤) |
|
||||
| 범인찾기 (v1.3.x) | AI(Claude Opus 5.5 high) 10명 평점 · 팀별 범인 · 근거, 기록 점수(OP.GG OP스코어 계산법) · 10/15분 라인전(LOL.PS 정의) | ✅ 완료 (실제 Claude E2E, 사이트 배포, [v1.3.4](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.3.4) · 리플레이 동기화는 Windows 실기 확인 뒤) |
|
||||
|
||||
## 저장소 구조
|
||||
|
||||
|
||||
4
app/package-lock.json
generated
4
app/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "gvr-app",
|
||||
"version": "1.3.3",
|
||||
"version": "1.3.4",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "gvr-app",
|
||||
"version": "1.3.3",
|
||||
"version": "1.3.4",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@discordjs/voice": "^0.19.2",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "gvr-app",
|
||||
"productName": "겜녹이",
|
||||
"version": "1.3.3",
|
||||
"version": "1.3.4",
|
||||
"description": "겜녹이 (Game Voice Recorder) - 게임 연동 디스코드 음성 기록",
|
||||
"private": true,
|
||||
"main": "dist/main.cjs",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// 음성채널에 들어갈 때 서버가 디스코드에서 받은 일회용 음성 접속 정보를 넘겨주고, 음성은 이 PC ↔ 디스코드로 바로 간다
|
||||
import type { DiscordGatewayAdapterCreator, DiscordGatewayAdapterLibraryMethods } from '@discordjs/voice';
|
||||
import type { BotGwChannel, BotGwFromApp, BotGwGuild, BotGwMember, BotGwToApp } from '@gvr/shared';
|
||||
import { ChannelType, Client, Events, GatewayIntentBits, MessageFlags, type Guild, type GuildMember, type VoiceBasedChannel } from 'discord.js';
|
||||
import { ActivityType, ChannelType, Client, Events, GatewayIntentBits, MessageFlags, type Guild, type GuildMember, type VoiceBasedChannel } from 'discord.js';
|
||||
import { EventEmitter } from 'node:events';
|
||||
import WebSocket from 'ws';
|
||||
import { logger } from '../util/log.js';
|
||||
@@ -70,14 +70,34 @@ export class LocalGateway extends EventEmitter implements BotGateway {
|
||||
super();
|
||||
}
|
||||
|
||||
/** 봇 상태 메시지: 음성채널에 있으면(= 녹음 중) 빨간 "녹음 중" (겜녹이 봇은 사이트 서버가 같은 일을 한다) */
|
||||
private recording: boolean | null = null;
|
||||
private updatePresence(): void {
|
||||
const c = this.client;
|
||||
if (!c?.isReady()) return;
|
||||
const on = c.guilds.cache.some((g) => !!g.members.me?.voice.channelId);
|
||||
if (on === this.recording) return;
|
||||
this.recording = on;
|
||||
c.user.setPresence(
|
||||
on
|
||||
? { status: 'dnd', activities: [{ type: ActivityType.Custom, name: 'custom', state: '🔴 녹음 중' }] }
|
||||
: { status: 'online', activities: [{ type: ActivityType.Custom, name: 'custom', state: '🎙️ 대기 중 · /녹음시작' }] },
|
||||
);
|
||||
}
|
||||
|
||||
async start(): Promise<void> {
|
||||
const c = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMembers] });
|
||||
this.client = c;
|
||||
c.on(Events.ClientReady, () => this.emit('ready'));
|
||||
this.recording = null;
|
||||
c.on(Events.ClientReady, () => {
|
||||
this.updatePresence();
|
||||
this.emit('ready');
|
||||
});
|
||||
c.on(Events.GuildCreate, () => this.emit('guilds'));
|
||||
c.on(Events.GuildDelete, () => this.emit('guilds'));
|
||||
c.on(Events.Error, (e) => log.error('discord 오류', e));
|
||||
c.on(Events.VoiceStateUpdate, (o, n) => {
|
||||
if (n.id === c.user?.id) this.updatePresence();
|
||||
const m = n.member ?? o.member;
|
||||
if (!m) return;
|
||||
const ch = n.channel;
|
||||
@@ -351,8 +371,17 @@ export class RemoteGateway extends EventEmitter implements BotGateway {
|
||||
// 이 유저가 가입하지 않은 서버
|
||||
if (this.watched?.id !== m.guildId) return;
|
||||
log.warn('이 디스코드 서버에 가입되어 있지 않아 녹음할 수 없습니다');
|
||||
this.wait?.resolve(null);
|
||||
this.wait = null;
|
||||
if (this.wait) {
|
||||
this.wait.resolve(null);
|
||||
this.wait = null;
|
||||
return;
|
||||
}
|
||||
// 지켜보던 중에 서버가 권한을 다시 확인하다 끊은 경우: 그대로 두면 슬래시 명령 · 음성 상태가 영영 안 오므로 1분 뒤 다시 요청한다
|
||||
// (정말 탈퇴했으면 다시 거절될 뿐이다)
|
||||
setTimeout(() => {
|
||||
const w = this.watched;
|
||||
if (w?.id === m.guildId && !this.wait) this.send({ t: 'watch', guildId: w.id, commands: w.commands });
|
||||
}, 60000).unref();
|
||||
return;
|
||||
case 'voiceState':
|
||||
if (this.watched?.id !== m.guildId) return;
|
||||
|
||||
@@ -304,11 +304,15 @@ test('봇 중계: 슬래시 명령은 그 서버를 지켜보는 앱으로 가
|
||||
const cmd = (name: string, user: string) =>
|
||||
new Promise<string>((resolve) => s.source.emit('command', { name, guildId: G, user: m(user, user), voiceChannel: { id: VC1, name: '일반' } } satisfies BotCommand, resolve));
|
||||
try {
|
||||
assert.equal(await cmd('녹음시작', SUPER), '지금 이 서버에서 켜져 있는 겜녹이 앱이 없습니다.');
|
||||
// 지켜보는 앱이 없는 서버의 명령은 서버가 받지 않는다 (봇 토큰을 직접 쓰는 v1.1.0 PC 가 응답하게)
|
||||
assert.match(await cmd('녹음시작', SUPER), /^지금 이 서버에서 켜져 있는 겜녹이 앱이 없습니다/);
|
||||
// 지켜보는 앱이 없는 서버의 명령은 서버가 잠깐 기다렸다가 받는다 (봇 토큰을 직접 쓰는 v1.1.0 PC 가 먼저 응답하게)
|
||||
assert.equal(s.source.wants?.(G), false);
|
||||
await a.gw.start();
|
||||
await b.gw.start();
|
||||
// 내 앱이 켜져 있어도 다른 서버를 녹음 대상으로 정해 두면 그렇다고 알려 준다 ("응답하지 않았어요" 대신)
|
||||
assert.match(await cmd('녹음시작', SUPER), /^내 겜녹이 앱이 이 서버에 아직 연결되지 않았습니다/);
|
||||
await a.gw.watch(OTHER_G, { commands: false });
|
||||
assert.match(await cmd('녹음시작', SUPER), /^내 겜녹이 앱이 다른 디스코드 서버를 녹음 대상으로 정해 두었습니다/);
|
||||
await a.gw.watch(G, { commands: false });
|
||||
assert.equal(s.source.wants?.(G), true);
|
||||
assert.equal(s.source.wants?.(OTHER_G), false);
|
||||
|
||||
@@ -302,7 +302,14 @@ export class BotBroker {
|
||||
/** 슬래시 명령을 맞는 앱으로 보내고 첫 응답을 돌려준다 */
|
||||
private async onCommand(cmd: BotCommand): Promise<string> {
|
||||
const here = [...this.conns].filter((c) => c.guildId === cmd.guildId).sort((a, b) => b.at - a.at);
|
||||
if (!here.length) return '지금 이 서버에서 켜져 있는 겜녹이 앱이 없습니다.';
|
||||
if (!here.length) {
|
||||
// 명령한 사람의 앱이 켜져 있는데 다른 서버를 녹음 대상으로 잡아 둔 경우를 알려 준다
|
||||
const own = [...this.conns].filter((c) => c.userId === cmd.user.id);
|
||||
this.log.info({ guild: cmd.guildId, user: cmd.user.id, cmd: cmd.name, apps: this.conns.size, own: own.map((c) => c.guildId) }, '슬래시 명령: 이 서버를 지켜보는 앱 없음');
|
||||
if (own.some((c) => c.guildId)) return '내 겜녹이 앱이 다른 디스코드 서버를 녹음 대상으로 정해 두었습니다. 게임 PC 의 겜녹이 설정 → 디스코드 → "녹음할 서버"를 이 서버로 바꿔 주세요.';
|
||||
if (own.length) return '내 겜녹이 앱이 이 서버에 아직 연결되지 않았습니다. 잠시 뒤 다시 시도하거나, 겜녹이 설정 → 디스코드에서 "녹음할 서버"를 확인해 주세요.';
|
||||
return '지금 이 서버에서 켜져 있는 겜녹이 앱이 없습니다. 게임 PC 에서 겜녹이를 켜고 로그인해 주세요.';
|
||||
}
|
||||
const owner = this.owners.get(cmd.guildId)?.conn;
|
||||
const mine = here.find((c) => c.userId === cmd.user.id);
|
||||
let targets: Conn[];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// 서버의 겜녹이 봇 디스코드 연결 (discord.js). bot-broker.ts 의 BotSource 구현
|
||||
import { EventEmitter } from 'node:events';
|
||||
import { ChannelType, Client, Events, GatewayIntentBits, MessageFlags, PermissionFlagsBits, type Guild, type GuildMember, type VoiceBasedChannel } from 'discord.js';
|
||||
import { ActivityType, ChannelType, Client, Events, GatewayIntentBits, MessageFlags, PermissionFlagsBits, type Guild, type GuildMember, type VoiceBasedChannel } from 'discord.js';
|
||||
import type { BotGwChannel, BotGwGuild, BotGwMember } from '@gvr/shared';
|
||||
import type { BotCommand, BotSource, BotVoiceEvent } from './bot-broker.js';
|
||||
|
||||
@@ -14,6 +14,13 @@ export const COMMANDS = [
|
||||
|
||||
const member = (m: GuildMember): BotGwMember => ({ id: m.id, name: m.displayName, avatar: m.displayAvatarURL({ size: 128 }), bot: m.user.bot });
|
||||
const guild = (g: Guild): BotGwGuild => ({ id: g.id, name: g.name, icon: g.iconURL({ size: 128 }) });
|
||||
/** 봇 상태 메시지: 어느 서버에서든 음성채널에 들어가 있으면(= 녹음 중) 빨간 "녹음 중", 아니면 대기 */
|
||||
export function botPresence(recording: boolean) {
|
||||
return recording
|
||||
? { status: 'dnd' as const, activities: [{ type: ActivityType.Custom, name: 'custom', state: '🔴 녹음 중' }] }
|
||||
: { status: 'online' as const, activities: [{ type: ActivityType.Custom, name: 'custom', state: '🎙️ 대기 중 · /녹음시작' }] };
|
||||
}
|
||||
|
||||
const isVoice = (c: { type: ChannelType } | null | undefined): c is VoiceBasedChannel => !!c && (c.type === ChannelType.GuildVoice || c.type === ChannelType.GuildStageVoice);
|
||||
|
||||
export class DiscordSource extends EventEmitter implements BotSource {
|
||||
@@ -26,6 +33,8 @@ export class DiscordSource extends EventEmitter implements BotSource {
|
||||
this.client = c;
|
||||
c.on(Events.ClientReady, () => {
|
||||
log.info({ bot: c.user?.tag, guilds: c.guilds.cache.size }, '겜녹이 봇 디스코드 연결');
|
||||
this.recording = null;
|
||||
this.updatePresence();
|
||||
this.emit('ready');
|
||||
});
|
||||
c.on(Events.GuildCreate, () => this.emit('guilds'));
|
||||
@@ -41,6 +50,7 @@ export class DiscordSource extends EventEmitter implements BotSource {
|
||||
c.on(Events.GuildDelete, () => this.emit('guilds'));
|
||||
c.on(Events.Error, (e) => log.error(e, '디스코드 오류'));
|
||||
c.on(Events.VoiceStateUpdate, (o, n) => {
|
||||
if (n.id === c.user?.id) this.updatePresence();
|
||||
const m = n.member ?? o.member;
|
||||
if (!m) return;
|
||||
const ch = n.channel;
|
||||
@@ -49,10 +59,14 @@ export class DiscordSource extends EventEmitter implements BotSource {
|
||||
});
|
||||
c.on(Events.InteractionCreate, async (i) => {
|
||||
if (!i.isChatInputCommand() || !i.guildId || !COMMANDS.some((x) => x.name === i.commandName)) return;
|
||||
if (this.wants && !this.wants(i.guildId)) return;
|
||||
// 이 서버를 지켜보는 앱이 없으면 1.5초 기다렸다가 응답한다: 봇 토큰을 직접 쓰는 옛 PC(v1.1.0)가 먼저 받았으면
|
||||
// 그쪽 응답을 그대로 두고(아래 deferReply 가 '이미 응답함'으로 실패), 아무도 받지 않았으면 이유를 알려 준다.
|
||||
// (예전에는 그냥 무시해서 디스코드에 "애플리케이션이 응답하지 않았어요"만 떴다)
|
||||
if (this.wants && !this.wants(i.guildId)) await new Promise((r) => setTimeout(r, 1500));
|
||||
try {
|
||||
await i.deferReply({ flags: MessageFlags.Ephemeral });
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
if (e?.code === 40060 || e?.code === 'InteractionAlreadyReplied') return;
|
||||
log.error(e, '명령 응답 실패');
|
||||
return;
|
||||
}
|
||||
@@ -68,6 +82,18 @@ export class DiscordSource extends EventEmitter implements BotSource {
|
||||
});
|
||||
}
|
||||
|
||||
private recording: boolean | null = null;
|
||||
/** 봇이 어느 서버에서든 음성채널에 있으면 녹음 중으로 상태 메시지를 바꾼다 */
|
||||
private updatePresence(): void {
|
||||
const c = this.client;
|
||||
if (!c.isReady()) return;
|
||||
const on = c.guilds.cache.some((g) => !!g.members.me?.voice.channelId);
|
||||
if (on === this.recording) return;
|
||||
this.recording = on;
|
||||
c.user.setPresence(botPresence(on));
|
||||
this.log.info({ recording: on }, '봇 상태 메시지 변경');
|
||||
}
|
||||
|
||||
login(token: string): Promise<string> {
|
||||
return this.client.login(token);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user