Files
game_voice_recorder/app/test/fixtures/culprit-seed.ts
EJClaw b230443409 v1.3.3: 따라갈 사람 목록 · 롤 채팅 OCR 제거 · 표시 이름(실명 숨기기)
- 따라갈 사람: 봇이 서버를 지켜보기 전 멤버 요청을 사이트 서버가 forbidden 으로 거절하고 앱이 오류를 숨겨 빈 목록이 됐다
  → 가입한 서버면 지켜보기 전에도 응답(source.members 가 멤버 확인), 앱은 오류 · 다시 불러오기 표시
  → 내 계정 → 관리자(GET /app/admins) → 이름순, 녹음할 서버를 바꾸면 봇을 다시 붙여 새 서버를 지켜봄
- 롤 채팅 OCR 제거: 앱 설정 · 마법사 · 진단 · lol.ts · 워커 ocr.py/ocr_* op · pywinrt/mss/Pillow · win-ci ocr_lang
  롤은 게임 중 전체/팀 채팅 API 가 없어 LCU(챔피언 선택 · 게임 후) + r3dlog(남아 있을 때, LCU 채팅을 지우지 않고 추가)
- 표시 이름: 서버 store.displayNames (세션 · 앱 유저 · 접속 기록 이름까지 바꿈), GET /app/names, PUT /app/admin/names,
  cli name. 앱은 받아서 users · 지난 범인 분석 이름을 바꾸고 이후 디스코드 이름 대신 저장. 관리자 탭에 편집 UI
- 저장소 시연 · 테스트 데이터 · 화면 캡처 · 계획서 PDF 의 실제 이름을 가짜 이름으로 교체
- 테스트: 앱 41 · 서버 16 · 워커 39 통과

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 02:42:57 +09:00

93 lines
4.2 KiB
TypeScript

// 범인찾기 테스트용: 앱 코어 일부(기록 DB · 타임라인 · 게임 관리 · 범인찾기)와 시연 경기 (앱 · 사이트 서버 테스트가 같이 쓴다)
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { Store } from '../../src/core/db/db.ts';
import { Timeline } from '../../src/core/timeline.ts';
import { GameAssets } from '../../src/core/games/assets.ts';
import { GameManager } from '../../src/core/games/manager.ts';
import { Culprit } from '../../src/core/culprit.ts';
import { buildApi } from '../../src/core/api/server.ts';
import { Bus } from '../../src/core/util/events.ts';
import { makeDemoValorant, AGENT } from './demo-matches.ts';
export const MIN = 60000;
export function setup() {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gvr-culprit-'));
const store = new Store(path.join(dir, 'db.sqlite'));
const timeline = new Timeline(store);
const assets = new GameAssets(path.join(dir, 'cache'));
// 네트워크 없이: 요원 이름 · 역할만 넣어 둔다
assets.val = {
at: Date.now(),
agents: {
[AGENT.jett]: { name: '제트', icon: '', role: '타격대', abilities: {} },
[AGENT.sage]: { name: '세이지', icon: '', role: '감시자', abilities: {} },
},
maps: {},
weapons: {},
tiers: {},
modes: {},
clientVersion: null,
} as any;
const bus = new Bus();
const stt: any = { onMatchStart: async () => undefined, onMatchEnd: async () => undefined };
const worker: any = { on: () => undefined, off: () => undefined };
const games = new GameManager(store, assets, worker, stt, timeline, bus, () => ({}) as any, () => null);
const culprit = new Culprit(store, timeline, games);
return { dir, store, timeline, assets, bus, games, culprit };
}
/** 발로란트 시연 경기 + 녹음 세션 + 대화 4문장 */
export function seedValorant(ctx: ReturnType<typeof setup>, opts: { sessionStartOffsetMs?: number; pending?: boolean } = {}) {
const { store, games } = ctx;
const VS = Date.now() - 3 * 3600_000;
const md = makeDemoValorant(VS);
const id = 'val-demo';
const users = [
{ id: 'u1', name: '하늘', puuid: 'p-sh' },
{ id: 'u2', name: '민수', puuid: 'p-ms' },
{ id: 'u9', name: '도윤', puuid: null },
];
for (const u of users) {
store.upsertUser({ id: u.id, name: u.name, avatar: null });
if (u.puuid) store.setAccounts(u.id, [{ puuid: u.puuid, riotId: `${u.name}#X` }]);
}
store.startSession('s1', 'g', 'c', '음성', VS - 5 * MIN + (opts.sessionStartOffsetMs ?? 0));
games.matchStarted({ id, game: 'valorant', startedAt: VS, map: md.matchInfo.mapId, mode: 'competitive', queue: 'competitive', detail: { live: true } });
games.matchEnded(id, VS + md.matchInfo.gameLengthMillis);
(games.adapters[0] as any).applyDetails(id, md, 'p-sh', VS);
const rounds = store.rounds(id);
const say = (uid: string, round: number, sec: number, text: string, status = 'realtime') => {
const ts = rounds[round - 1].combat_at + sec * 1000;
const uid2 = `${uid}-${round}-${sec}`;
store.insertUtterance({ id: uid2, session_id: 's1', user_id: uid, started_at: ts, ended_at: ts + 1500, audio_path: null, match_id: id });
if (status !== 'pending')
store.updateUtteranceResult(uid2, { text, raw_text: text, words: [], noise: false, noise_reason: null, confidence: 0.9, lufs: -20, gain_db: 0, model: 'small', status: status as any });
};
say('u1', 3, 5, '현우야 같이 가 기다려 둘 있어');
say('u2', 3, 9, '아 그냥 간다 내가 뚫을게');
say('u9', 5, 2, '나 돈 없어 세이브할게');
say('u1', 7, 4, '스파이크 설치됐어 해체 들어가', opts.pending ? 'pending' : 'realtime');
store.endSession('s1', VS + md.matchInfo.gameLengthMillis + 5 * MIN);
return { id, VS, md };
}
/** 앱 로컬 API (사이트 서버가 중계로 부르는 것과 같은 Fastify) */
export function culpritApi(ctx: ReturnType<typeof setup>) {
return buildApi({
store: ctx.store,
timeline: ctx.timeline,
games: ctx.games,
dict: {} as any,
culprit: ctx.culprit,
bus: ctx.bus,
settings: () => ({}) as any,
trainingDir: () => ctx.dir,
overviewExtra: () => ({ guild: null, recording: { active: false, channel: null, since: null, participants: [] } }),
version: 'test',
});
}