Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f7bf1cb86 | ||
|
|
0dd46a5e16 | ||
|
|
db2f1866e4 | ||
|
|
125e2a22ee |
14
README.md
14
README.md
@@ -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.5](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.3.5) (`GameVoiceRecorder-1.3.5-win-x64.zip` 권장, 단일 파일 `GameVoiceRecorder-1.3.5-portable.exe`) · 처음 버전 [v1.0.0](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.0.0)
|
||||
|
||||
## 로그인 · 관리자 (v1.2.0~)
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
- 앱은 시작할 때와 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.5 바뀐 점
|
||||
|
||||
- **표시 이름 빈틈**: 표시 이름을 정하기 전에 시작한 범인 분석이 정한 뒤에 저장되면 결과 본문에 예전 이름이 남을 수 있었다 (이미 이름이 바뀐 유저는 다시 훑지 않았음). 이제 가린 예전 이름을 기억해 두고(`meta.hidden_names`), 분석을 저장할 때마다 · 이름을 다시 받을 때마다 모든 분석에서 바꾼다
|
||||
- 상태 메시지 실제 확인: `site/server/scripts/presence-e2e.mts` (사이트 서버 코드로 봇을 빈 음성채널에 넣었다 빼며 확인)
|
||||
|
||||
## v1.3.4 바뀐 점
|
||||
|
||||
- **슬래시 명령 응답**: 그 디스코드 서버를 지켜보는 겜녹이 앱이 없으면 사이트 서버가 명령을 무시해서 디스코드에 "애플리케이션이 응답하지 않았어요"만 떴다 (봇 토큰을 직접 쓰는 옛 v1.1.0 PC 와 겹치지 않게 넣은 동작). 이제 1.5초 기다렸다가 아무도 받지 않았으면 이유를 답한다: 앱이 꺼져 있음 / 내 앱이 다른 서버를 녹음 대상으로 정해 둠 / 아직 연결 중. 앱은 서버가 권한을 다시 확인하다 지켜보기를 끊으면 1분 뒤 다시 요청한다
|
||||
- **봇 상태 메시지**: 녹음 중(봇이 어느 서버에서든 음성채널에 있음)이면 빨간 상태(다른 용무 중) + "🔴 녹음 중", 아니면 "🎙️ 대기 중 · /녹음시작". 겜녹이 봇은 사이트 서버가, 다른 봇 모드는 앱이 바꾼다. 봇 하나가 여러 서버에 들어가 있어서 채널 이름은 넣지 않는다
|
||||
|
||||
## v1.3.3 바뀐 점
|
||||
|
||||
- **따라갈 사람 목록**: 녹음할 서버의 멤버가 모두 나온다. 내 계정이 맨 위, 그다음 관리자(최고 관리자 포함), 나머지는 이름순. 예전에는 봇이 서버를 지켜보기 전에 목록을 요청하면 사이트 서버가 거절했고 앱이 그 오류를 숨겨 "선택 안 함"만 보였다. 이제 가입한 서버면 바로 받고, 실패하면 오류와 다시 불러오기 버튼을 보여 준다. 녹음할 서버를 바꾸면 봇이 새 서버를 바로 지켜본다. 서버: `GET /app/admins`
|
||||
@@ -71,7 +81,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.2](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.3.2) · 리플레이 동기화는 Windows 실기 확인 뒤) |
|
||||
| 범인찾기 (v1.3.x) | AI(Claude Opus 5.5 high) 10명 평점 · 팀별 범인 · 근거, 기록 점수(OP.GG OP스코어 계산법) · 10/15분 라인전(LOL.PS 정의) | ✅ 완료 (실제 Claude E2E, 사이트 배포, [v1.3.5](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.3.5) · 리플레이 동기화는 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.5",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "gvr-app",
|
||||
"version": "1.3.3",
|
||||
"version": "1.3.5",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@discordjs/voice": "^0.19.2",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "gvr-app",
|
||||
"productName": "겜녹이",
|
||||
"version": "1.3.3",
|
||||
"version": "1.3.5",
|
||||
"description": "겜녹이 (Game Voice Recorder) - 게임 연동 디스코드 음성 기록",
|
||||
"private": true,
|
||||
"main": "dist/main.cjs",
|
||||
|
||||
@@ -146,7 +146,8 @@ export class Culprit {
|
||||
this.store.db.prepare('UPDATE culprit_analyses SET current=0 WHERE match_id=?').run(matchId);
|
||||
this.store.db
|
||||
.prepare('INSERT OR REPLACE INTO culprit_analyses(id,match_id,created_at,created_by,model,current,result,meta) VALUES(?,?,?,?,?,1,?,?)')
|
||||
.run(id, matchId, a.createdAt, JSON.stringify(a.createdBy), a.model, JSON.stringify({ result: a.result, players: a.players }), JSON.stringify(a.meta));
|
||||
// 표시 이름(실명 숨기기)을 정하기 전에 시작한 분석이 뒤늦게 와도 예전 이름이 남지 않게 저장할 때 바꾼다
|
||||
.run(id, matchId, a.createdAt, JSON.stringify(this.store.scrubCreatedBy(a.createdBy)), a.model, this.store.scrubNames(JSON.stringify({ result: a.result, players: a.players })), JSON.stringify(a.meta));
|
||||
});
|
||||
tx();
|
||||
return this.current(matchId)!;
|
||||
|
||||
@@ -126,6 +126,7 @@ export class Store {
|
||||
ON CONFLICT(id) DO UPDATE SET name=excluded.name, avatar=excluded.avatar, updated_at=excluded.updated_at`,
|
||||
)
|
||||
.run(u.id, this.displayNames()[u.id] ?? u.name, colorFor(u.id), u.avatar, now);
|
||||
this.rememberHidden(u.id, u.name);
|
||||
return this.getUser(u.id)!;
|
||||
}
|
||||
|
||||
@@ -141,6 +142,38 @@ export class Store {
|
||||
}
|
||||
return this.names!;
|
||||
}
|
||||
/** 표시 이름으로 가린 예전 이름들 (아이디 → 디스코드에서 받은 이름들). 범인 분석 본문 등 글 속 이름을 바꿀 때 쓴다 */
|
||||
private hiddenNames(): Record<string, string[]> {
|
||||
try {
|
||||
return JSON.parse(this.meta('hidden_names') || '{}');
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
private rememberHidden(id: string, old: string): void {
|
||||
const name = this.displayNames()[id];
|
||||
if (!name || old === name || old.trim().length < 2) return;
|
||||
const h = this.hiddenNames();
|
||||
if (h[id]?.includes(old)) return;
|
||||
(h[id] ||= []).push(old);
|
||||
this.setMeta('hidden_names', JSON.stringify(h));
|
||||
}
|
||||
/** 글(JSON 문자열 포함) 속 예전 이름을 표시 이름으로 바꾼다. 긴 이름부터 (짧은 이름이 긴 이름의 일부일 수 있어서) */
|
||||
scrubNames(text: string): string {
|
||||
const names = this.displayNames();
|
||||
const pairs: [string, string][] = [];
|
||||
for (const [id, olds] of Object.entries(this.hiddenNames())) if (names[id]) for (const o of olds) pairs.push([o, names[id]]);
|
||||
pairs.sort((x, y) => y[0].length - x[0].length);
|
||||
const j = (x: string) => JSON.stringify(x).slice(1, -1);
|
||||
for (const [o, n] of pairs) text = text.split(j(o)).join(j(n));
|
||||
return text;
|
||||
}
|
||||
/** 분석을 만든 사람 { id, name }: 표시 이름이 있으면 그것으로 */
|
||||
scrubCreatedBy<T extends { id?: string; name?: string }>(by: T): T {
|
||||
const n = by?.id ? this.displayNames()[by.id] : undefined;
|
||||
if (n && by.name && by.name !== n) this.rememberHidden(by.id!, by.name);
|
||||
return n ? { ...by, name: n } : by;
|
||||
}
|
||||
/** 새 표시 이름을 저장하고, 이미 저장된 유저 이름 · 지난 범인 분석에 남은 예전 이름도 바꾼다 */
|
||||
setDisplayNames(map: Record<string, string>): void {
|
||||
const names: Record<string, string> = {};
|
||||
@@ -148,23 +181,25 @@ export class Store {
|
||||
this.names = names;
|
||||
this.setMeta('display_names', JSON.stringify(names));
|
||||
const culprit = !!this.db.prepare(`SELECT 1 FROM sqlite_master WHERE type='table' AND name='culprit_analyses'`).get();
|
||||
const j = (x: string) => JSON.stringify(x).slice(1, -1);
|
||||
this.db.transaction(() => {
|
||||
for (const [id, name] of Object.entries(names)) {
|
||||
const u = this.getUser(id);
|
||||
if (!u || u.name === name) continue;
|
||||
this.rememberHidden(id, u.name);
|
||||
this.db.prepare('UPDATE users SET name=? WHERE id=?').run(name, id);
|
||||
if (culprit && u.name.length >= 2) this.db.prepare('UPDATE culprit_analyses SET result=replace(result,?,?)').run(j(u.name), j(name));
|
||||
}
|
||||
if (!culprit) return;
|
||||
for (const r of this.db.prepare('SELECT id, created_by FROM culprit_analyses').all() as { id: string; created_by: string }[]) {
|
||||
// 건너뛰지 않고 매번 모든 분석을 다시 훑는다 (이름을 바꾸기 전에 시작한 분석이 뒤늦게 저장된 경우도 고친다)
|
||||
for (const r of this.db.prepare('SELECT id, created_by, result FROM culprit_analyses').all() as { id: string; created_by: string; result: string }[]) {
|
||||
let by: any;
|
||||
try {
|
||||
by = JSON.parse(r.created_by);
|
||||
} catch {
|
||||
continue;
|
||||
by = null;
|
||||
}
|
||||
if (by?.id && names[by.id] && by.name !== names[by.id]) this.db.prepare('UPDATE culprit_analyses SET created_by=? WHERE id=?').run(JSON.stringify({ ...by, name: names[by.id] }), r.id);
|
||||
const createdBy = by ? JSON.stringify(this.scrubCreatedBy(by)) : r.created_by;
|
||||
const result = this.scrubNames(r.result);
|
||||
if (createdBy !== r.created_by || result !== r.result) this.db.prepare('UPDATE culprit_analyses SET created_by=?, result=? WHERE id=?').run(createdBy, result, r.id);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -199,6 +199,21 @@ test('범인찾기 API: 목록 · 상세 · 내부 전용 경로', async () => {
|
||||
assert.equal(info2.history.length, 2);
|
||||
assert.equal(info2.analysis!.model, 'm2');
|
||||
assert.equal(info2.history.filter((h) => h.current).length, 1);
|
||||
|
||||
// 표시 이름(실명 숨기기): 이름을 바꾸기 전에 시작한 분석(자료 · 요약에 예전 이름)이 바꾼 뒤에 도착해도 예전 이름이 남지 않는다
|
||||
ctx.store.setDisplayNames({ u1: '별명' });
|
||||
assert.equal(ctx.store.getUser('u1')?.name, '별명');
|
||||
const late = { ...result, summary: '하늘이 캐리했다' };
|
||||
await api.inject({ method: 'PUT', url: `/api/culprit/internal/${id}/result`, headers: { 'x-gvr-internal': '1' }, payload: { result: late, players: input.players, model: 'm3', createdBy: { id: 'u1', name: '하늘' }, meta: {} } });
|
||||
const raw = () => JSON.stringify(ctx.store.db.prepare('SELECT created_by, result FROM culprit_analyses').all());
|
||||
assert.ok(!raw().includes('하늘'), raw());
|
||||
const info3 = (await api.inject({ url: `/api/culprit/matches/${id}` })).json() as CulpritMatchInfo;
|
||||
assert.equal(info3.analysis!.result.summary, '별명이 캐리했다');
|
||||
assert.equal(info3.analysis!.createdBy.name, '별명');
|
||||
assert.ok(info3.analysis!.players.some((p) => p.name === '별명'));
|
||||
// 같은 이름으로 다시 받아도(이미 바뀐 유저는 건너뛰는 경우) 그대로 깨끗하다
|
||||
ctx.store.setDisplayNames({ u1: '별명' });
|
||||
assert.ok(!raw().includes('하늘'));
|
||||
await api.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -167,3 +167,26 @@ VOICE E2E PASS
|
||||
- AI 평점과 기록 점수 차: 평균 0.4점 (롤 P2 는 "용 셋 · 유충 · 바론 싹쓸이"를 근거로 기록 3.0 → AI 5.0)
|
||||
- 테스트: 앱 40개 · 사이트 서버 16개 통과 (서버 테스트에 "자료에 기록 점수 칸, 지시문 '평점은 기록 점수에서 출발', OP.GG 실제 점수 없음" 확인 추가)
|
||||
- 배포: 사이트 서버 다시 배포 (서버 번들 · 화면에 OP.GG 접속 코드 없음 확인, 지시문 '평점은 기록 점수에서 출발'), Windows CI (b8e76ab, full) 8개 모두 PASS · 앱 버전 1.3.2 → Gitea 릴리스 v1.3.2 (v1.3.0 · v1.3.1 에 새 버전 안내)
|
||||
|
||||
## v1.3.3 — 따라갈 사람 목록 · 롤 채팅 OCR 제거 · 표시 이름 (2026-10-16)
|
||||
|
||||
- 따라갈 사람 원인: 사이트 서버 봇 중계가 "지켜보는 서버"가 아니면 멤버 요청을 `forbidden` 으로 거절했고, 앱(`guildMembers`)이 오류를 삼켜 빈 목록이 됐다. 설정 창은 봇이 준비되자마자(지켜보기 전) 요청하므로 "선택 안 함"만 남았다. `bot-gateway.test.ts` 에 지켜보기 전 요청을 넣어 예전 서버 코드에서 `forbidden` 으로 실패하는 것을 확인한 뒤 고침. 실제 사이트 서버 봇은 M&L 87명 · 다른 서버 27명을 정상으로 받음
|
||||
- 정렬: 내 계정 → 관리자(`GET /app/admins`) → 이름순 (mock 화면 확인: `민준 (나)`, `지호 · 관리자`, 나머지)
|
||||
- 롤 채팅: LCU · 게임 클라이언트 API(2999) 모두 게임 중 전체 · 팀 채팅을 주지 않는다 (`lol-game-client-chat` 은 귓속말 · 파티 메시지 보내기만, 게임 중 채팅 이벤트는 Overwolf 전용이며 저장 금지). OCR 코드 · 의존성(pywinrt · mss · Pillow) 제거, r3dlog 채팅은 LCU 채팅을 지우지 않고 추가
|
||||
- 표시 이름: 서버 `displayNames` · `GET /app/names` · `PUT /app/admin/names`(최고 관리자), 앱은 users · 지난 범인 분석 이름 교체. 운영 서버에 두 최고 관리자 계정 표시 이름 설정, server.json 에 실명 0건
|
||||
- 저장소: 시연 · 테스트 데이터 · 화면 캡처(`docs/dev/screens`, `docs/report/img`, `docs/report/culprit/img`) · 계획서 PDF 3개를 가짜 이름으로 다시 만듦 (PDF 쪽수 그대로)
|
||||
- 테스트: 앱 41 · 사이트 서버 16 · 워커 39 통과, 앱/화면 타입 검사 통과
|
||||
- 배포: 사이트 서버 다시 배포(화면 번들 실명 0건, 새 API 401 응답 확인), Windows CI (b230443, full) 7개 모두 PASS (ocr_lang 단계 삭제) · 앱 버전 1.3.3 → Gitea 릴리스 v1.3.3 (v1.3.2 에 새 버전 안내)
|
||||
|
||||
## v1.3.4 — 슬래시 명령 응답 · 녹음 중 봇 상태 메시지 (2026-10-16)
|
||||
|
||||
- 원인: 사이트 서버 `discord-source.ts` 가 "그 서버를 지켜보는 앱이 없으면" 슬래시 명령을 응답 없이 무시했다 (옛 v1.1.0 PC 와 응답이 겹치지 않게 넣은 동작) → 디스코드 "애플리케이션이 응답하지 않았어요". 이제 1.5초 기다린 뒤 이유를 답한다 (`bot-gateway.test.ts`: 앱 없음 · 내 앱이 다른 서버를 지켜봄 · 아직 연결 중 세 경우 확인)
|
||||
- 앱: 지켜보던 중 `watch_denied` 를 받으면 1분 뒤 다시 지켜보기
|
||||
- 상태 메시지: 테스트 봇으로 `dnd + "🔴 녹음 중"` · `online + "🎙️ 대기 중 · /녹음시작"` 을 디스코드가 받는 것 확인, 배포 뒤 실제 겜녹이 봇 상태가 "🎙️ 대기 중 · /녹음시작" 인 것을 같은 서버의 테스트 봇으로 읽어 확인
|
||||
- 테스트: 앱 41 · 사이트 서버 16 통과. Windows CI (db2f186, full) 7개 모두 PASS · 앱 버전 1.3.4 → Gitea 릴리스 v1.3.4 (v1.3.3 에 새 버전 안내)
|
||||
|
||||
## v1.3.5 — 표시 이름 빈틈 · 상태 메시지 실제 확인 (2026-10-16)
|
||||
|
||||
- 표시 이름: 이름을 바꾸기 전에 시작한 분석이 바꾼 뒤 저장되면 예전 이름이 남던 빈틈 (`setDisplayNames` 가 이미 바뀐 유저를 건너뜀 + 저장 경로에서 이름을 바꾸지 않음). `culprit.test.ts` 에 "바꾼 뒤 도착한 분석 · 다시 받기" 회귀 테스트 추가, 예전 코드에서 실패하는 것 확인 뒤 고침
|
||||
- 상태 메시지 실제 디스코드 확인 (`site/server/scripts/presence-e2e.mts`, 테스트 봇 · 빈 음성채널): 들어간 뒤 0.2초에 `dnd "🔴 녹음 중"`, 나온 뒤 0.2초에 `online "🎙️ 대기 중 · /녹음시작"` (디스코드가 보낸 음성 상태 이벤트로 바뀜)
|
||||
- 테스트: 앱 41 · 사이트 서버 16 통과
|
||||
|
||||
25
site/server/scripts/presence-e2e.mts
Normal file
25
site/server/scripts/presence-e2e.mts
Normal file
@@ -0,0 +1,25 @@
|
||||
// 실제 디스코드: DiscordSource(사이트 서버 코드)로 봇을 음성채널에 넣었다 빼며 상태 메시지가 바뀌는지 본다
|
||||
import { Client, GatewayIntentBits } from 'discord.js';
|
||||
import { DiscordSource } from '../src/discord-source.ts';
|
||||
// 사용: TB=<봇 토큰> GUILD=<서버 아이디> VC=<빈 음성채널 아이디> node --import tsx scripts/presence-e2e.mts
|
||||
const G = process.env.GUILD!, VC = process.env.VC!;
|
||||
const t0 = Date.now();
|
||||
const at = () => `${((Date.now() - t0) / 1000).toFixed(1)}s`;
|
||||
const log = { info: (o: any, m?: string) => console.log(at(), 'LOG', m, JSON.stringify(o)), error: (o: any, m?: string) => console.log(at(), 'ERR', m, o?.message ?? o) };
|
||||
const src = new DiscordSource(log);
|
||||
// 관찰자: 같은 서버의 다른 세션이 디스코드에서 받은 봇 상태 (presence intent 가 있으면)
|
||||
const obs = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildPresences, GatewayIntentBits.GuildMembers] });
|
||||
obs.on('presenceUpdate', (_o, n) => n.userId === src.client.user?.id && console.log(at(), 'OBSERVED', n.status, JSON.stringify(n.activities.map((a) => a.state))));
|
||||
await src.login(process.env.TB!);
|
||||
await new Promise((r) => src.once('ready', r));
|
||||
await obs.login(process.env.TB!).catch((e) => console.log('observer off:', e.message));
|
||||
await new Promise((r) => setTimeout(r, 3000));
|
||||
const send = (ch: string | null) => src.voiceAdapter(G, { server: () => undefined, state: () => undefined }).send({ op: 4, d: { guild_id: G, channel_id: ch, self_mute: true, self_deaf: true } });
|
||||
console.log(at(), 'JOIN'); send(VC);
|
||||
await new Promise((r) => setTimeout(r, 5000));
|
||||
console.log(at(), 'presence now', src.client.user!.presence.status, JSON.stringify(src.client.user!.presence.activities.map((a) => a.state)), 'inVoice', !!src.client.guilds.cache.get(G)!.members.me!.voice.channelId);
|
||||
console.log(at(), 'LEAVE'); send(null);
|
||||
await new Promise((r) => setTimeout(r, 5000));
|
||||
console.log(at(), 'presence now', src.client.user!.presence.status, JSON.stringify(src.client.user!.presence.activities.map((a) => a.state)), 'inVoice', !!src.client.guilds.cache.get(G)!.members.me!.voice.channelId);
|
||||
await obs.destroy().catch(() => undefined);
|
||||
await src.destroy();
|
||||
@@ -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