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>
This commit is contained in:
@@ -203,6 +203,21 @@ export class AppAuth extends EventEmitter {
|
||||
if (token) await this.call('POST', '/auth/app/logout', {}, token).catch(() => undefined);
|
||||
}
|
||||
|
||||
/** 관리자 · 최고 관리자 아이디 (따라갈 사람 목록 정렬용) */
|
||||
async adminIds(): Promise<string[]> {
|
||||
const r = await this.call<{ ids: string[] }>('GET', '/app/admins');
|
||||
return Array.isArray(r?.ids) ? r.ids : [];
|
||||
}
|
||||
|
||||
/** 표시 이름 (실명 숨기기): 디스코드 아이디 → 이름 */
|
||||
async displayNames(): Promise<Record<string, string>> {
|
||||
const r = await this.call<{ names: Record<string, string> }>('GET', '/app/names');
|
||||
return r?.names && typeof r.names === 'object' ? r.names : {};
|
||||
}
|
||||
adminSetDisplayName(id: string, name: string): Promise<{ names: Record<string, string> }> {
|
||||
return this.call('PUT', '/app/admin/names', { id: id.trim(), name: name.trim() });
|
||||
}
|
||||
|
||||
// ---- 관리자 화면 (서버가 역할을 다시 확인한다)
|
||||
adminUsers(): Promise<{ users: AppUserRow[] }> {
|
||||
return this.call('GET', '/app/admin/users');
|
||||
|
||||
@@ -125,9 +125,49 @@ export class Store {
|
||||
`INSERT INTO users(id,name,color,avatar,updated_at) VALUES(?,?,?,?,?)
|
||||
ON CONFLICT(id) DO UPDATE SET name=excluded.name, avatar=excluded.avatar, updated_at=excluded.updated_at`,
|
||||
)
|
||||
.run(u.id, u.name, colorFor(u.id), u.avatar, now);
|
||||
.run(u.id, this.displayNames()[u.id] ?? u.name, colorFor(u.id), u.avatar, now);
|
||||
return this.getUser(u.id)!;
|
||||
}
|
||||
|
||||
// 표시 이름 (실명 숨기기): 사이트 서버에 정해 둔 이름을 디스코드 이름 대신 저장한다
|
||||
private names: Record<string, string> | null = null;
|
||||
displayNames(): Record<string, string> {
|
||||
if (!this.names) {
|
||||
try {
|
||||
this.names = JSON.parse(this.meta('display_names') || '{}');
|
||||
} catch {
|
||||
this.names = {};
|
||||
}
|
||||
}
|
||||
return this.names!;
|
||||
}
|
||||
/** 새 표시 이름을 저장하고, 이미 저장된 유저 이름 · 지난 범인 분석에 남은 예전 이름도 바꾼다 */
|
||||
setDisplayNames(map: Record<string, string>): void {
|
||||
const names: Record<string, string> = {};
|
||||
for (const [id, name] of Object.entries(map)) if (typeof name === 'string' && name.trim()) names[id] = name.trim();
|
||||
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.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 }[]) {
|
||||
let by: any;
|
||||
try {
|
||||
by = JSON.parse(r.created_by);
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
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);
|
||||
}
|
||||
})();
|
||||
}
|
||||
getUser(id: string): UserRow | undefined {
|
||||
return this.db.prepare('SELECT * FROM users WHERE id=?').get(id) as UserRow | undefined;
|
||||
}
|
||||
|
||||
@@ -128,24 +128,13 @@ export async function runDiagnostics(opts: {
|
||||
});
|
||||
}
|
||||
|
||||
// 5. 채팅 OCR (한국어 OCR 설치 여부 + 정확도)
|
||||
try {
|
||||
const r = await opts.worker.request('ocr_image', { path: path.join(opts.resourcesDir, 'diag', 'lol-chat-sample.png'), lang: 'ko' }, 60000);
|
||||
const lines: string[] = (r.lines || []).map((l: any) => l.text ?? l);
|
||||
const expect = ['드래곤 가자', 'gg', '바텀 갱 간다'];
|
||||
const hit = expect.filter((e) => lines.some((l) => l.replace(/\s/g, '').includes(e.replace(/\s/g, '')))).length;
|
||||
add({ id: 'ocr', label: '채팅 OCR (한국어)', ok: hit >= 2, detail: `예시 3줄 중 ${hit}줄 인식: ${lines.join(' / ')}`, data: r });
|
||||
} catch (e: any) {
|
||||
add({ id: 'ocr', label: '채팅 OCR (한국어)', ok: false, detail: e.message });
|
||||
}
|
||||
|
||||
// 6. r3dlog 채팅
|
||||
// 5. r3dlog 채팅 (롤은 게임 중 채팅 API 가 없어 로그 파일에 남을 때만 쓴다)
|
||||
const logs = opts.lolLogsDir || (lcu?.installDir ? path.join(lcu.installDir, 'Logs', 'GameLogs') : null);
|
||||
if (!logs || !fs.existsSync(logs)) add({ id: 'r3dlog', label: '롤 로그 파일 채팅', ok: null, detail: '로그 폴더를 찾지 못했습니다 (롤을 한 판 한 뒤 확인)' });
|
||||
else {
|
||||
try {
|
||||
const r = await opts.worker.request('r3dlog_check', { logs_dir: logs }, 30000);
|
||||
add({ id: 'r3dlog', label: '롤 로그 파일 채팅', ok: r.found_chat, detail: r.found_chat ? `채팅이 남아 있음 → OCR 대신 사용 (${r.file})` : '로그에 채팅이 없음 → 화면 OCR 사용', data: r });
|
||||
add({ id: 'r3dlog', label: '롤 로그 파일 채팅', ok: r.found_chat ? true : null, detail: r.found_chat ? `채팅이 남아 있음 → 게임 중 채팅을 경기 뒤에 붙임 (${r.file})` : '로그에 채팅이 없음 → 게임 중 전체 · 팀 채팅은 기록되지 않음 (챔피언 선택 · 게임 후 채팅은 LCU 로 기록)', data: r });
|
||||
} catch (e: any) {
|
||||
add({ id: 'r3dlog', label: '롤 로그 파일 채팅', ok: false, detail: e.message });
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ const DRAGON_KO: Record<string, string> = {
|
||||
* 리그 오브 레전드 어댑터 (보고서 6-5).
|
||||
* - 게임 클라이언트 API(127.0.0.1:2999): 게임 시간, 10명 KDA·CS·아이템, 킬·오브젝트 이벤트
|
||||
* - 롤 클라이언트(LCU): 경기 ID·결과·경기 기록(타임라인), 챔피언 선택·게임 후 채팅
|
||||
* - 게임 중 채팅: 화면 OCR (STT 워커) 또는 로그 파일(남아 있을 때)
|
||||
* - 게임 중 전체 · 팀 채팅: 롤은 이걸 주는 API 가 없다 (LCU · 게임 클라이언트 API 모두). 화면 글자 인식(OCR)은 쓰지 않고,
|
||||
* 게임 로그 파일(r3dlog)에 채팅이 남아 있을 때만 경기 뒤에 읽는다
|
||||
*/
|
||||
export class LolAdapter implements GameAdapter {
|
||||
readonly game = 'lol' as const;
|
||||
@@ -61,15 +62,10 @@ export class LolAdapter implements GameAdapter {
|
||||
private pendingChat: EventRow[] = [];
|
||||
private detailQueue = new Map<string, { gameId: number; tries: number; endedAt: number; startedAt: number }>();
|
||||
private summonerNames = new Map<string, string>();
|
||||
private ocrSeen = new Set<string>();
|
||||
private lastMatchId: string | null = null;
|
||||
private lastErr = '';
|
||||
|
||||
constructor(private host: AdapterHost) {
|
||||
host.worker.on('event', (ev: any) => {
|
||||
if (ev.event === 'ocr_line') this.onOcrLine(ev);
|
||||
});
|
||||
}
|
||||
constructor(private host: AdapterHost) {}
|
||||
|
||||
start(): void {
|
||||
if (this.timer) return;
|
||||
@@ -80,7 +76,6 @@ export class LolAdapter implements GameAdapter {
|
||||
if (this.timer) clearInterval(this.timer);
|
||||
if (this.lcuTimer) clearInterval(this.lcuTimer);
|
||||
this.timer = this.lcuTimer = null;
|
||||
if (this.live) void this.host.worker.request('ocr_stop', {}, 5000).catch(() => undefined);
|
||||
}
|
||||
status() {
|
||||
return { connected: !!this.lcu || !!this.live, inMatch: !!this.live && !this.live.ended, detail: this.lastErr || undefined };
|
||||
@@ -148,7 +143,6 @@ export class LolAdapter implements GameAdapter {
|
||||
ended: false,
|
||||
};
|
||||
this.lastMatchId = id;
|
||||
this.ocrSeen.clear();
|
||||
this.host.matchStarted({
|
||||
id,
|
||||
game: 'lol',
|
||||
@@ -161,7 +155,6 @@ export class LolAdapter implements GameAdapter {
|
||||
// 버퍼해 둔 챔피언 선택 채팅을 이 경기에 붙인다
|
||||
for (const e of this.pendingChat) this.host.event({ ...e, match_id: id, id: `${id}:${e.id}` });
|
||||
this.pendingChat = [];
|
||||
void this.startOcr();
|
||||
log.info(`롤 경기 시작 감지 ${id}`);
|
||||
}
|
||||
const m = this.live;
|
||||
@@ -307,7 +300,6 @@ export class LolAdapter implements GameAdapter {
|
||||
if (!m || m.ended) return;
|
||||
m.ended = true;
|
||||
const now = Date.now();
|
||||
void this.host.worker.request('ocr_stop', {}, 5000).catch(() => undefined);
|
||||
this.host.matchEnded(m.id, now);
|
||||
this.host.matchUpdated(m.id, {
|
||||
result: JSON.stringify({ win, score: null }),
|
||||
@@ -323,19 +315,7 @@ export class LolAdapter implements GameAdapter {
|
||||
}, 60000).unref();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ 채팅 OCR · 로그
|
||||
private async startOcr(): Promise<void> {
|
||||
const s = this.host.settings().games;
|
||||
if (!s.lolChatOcr || process.platform !== 'win32') return;
|
||||
try {
|
||||
await this.host.worker.request('ocr_start', { window_title: 'League of Legends (TM) Client', region: s.lolOcrRegion, fps: 3, lang: 'ko' }, 15000);
|
||||
log.info('롤 채팅 OCR 시작');
|
||||
} catch (e: any) {
|
||||
this.lastErr = `채팅 OCR: ${e.message}`;
|
||||
log.warn('채팅 OCR 시작 실패', e);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ 게임 중 채팅 (로그 파일)
|
||||
private chatRow(m: LiveMatch, key: string, gameTimeS: number | null, ts: number, p: any, source: ChatData['source']): EventRow {
|
||||
const sender = this.findPlayer(m, p.sender);
|
||||
const ts2 = gameTimeS !== null ? m.startedAt + gameTimeS * 1000 : ts;
|
||||
@@ -363,18 +343,7 @@ export class LolAdapter implements GameAdapter {
|
||||
};
|
||||
}
|
||||
|
||||
private onOcrLine(ev: any): void {
|
||||
const m = this.live;
|
||||
if (!m || m.ended || !ev.parsed?.message) return;
|
||||
const p = ev.parsed;
|
||||
const key = `${p.game_time ?? ''}|${p.sender ?? ''}|${p.message}`;
|
||||
if (this.ocrSeen.has(key)) return;
|
||||
this.ocrSeen.add(key);
|
||||
const gts = typeof p.game_time_s === 'number' ? p.game_time_s : null;
|
||||
this.host.event(this.chatRow(m, hash(key), gts, ev.ts || Date.now(), p, 'ocr'));
|
||||
}
|
||||
|
||||
/** 로그 파일에 채팅이 남아 있으면 OCR 보다 정확하므로 그걸로 바꾼다 */
|
||||
/** 경기가 끝나면 로그 파일에 남은 게임 중 채팅을 붙인다 (LCU 로 받은 챔피언 선택 · 게임 후 채팅은 그대로 둔다) */
|
||||
private async readLogChat(m: LiveMatch): Promise<void> {
|
||||
const dir = this.host.settings().games.lolLogsDir || (this.lcu?.installDir ? `${this.lcu.installDir}\\Logs\\GameLogs` : null);
|
||||
if (!dir) return;
|
||||
@@ -385,8 +354,8 @@ export class LolAdapter implements GameAdapter {
|
||||
const rows = lines.map((p: any, i: number) =>
|
||||
this.chatRow(m, `${i}-${hash(`${p.game_time_s}|${p.sender}|${p.message}`)}`, typeof p.game_time_s === 'number' ? p.game_time_s : null, m.startedAt, p, 'log'),
|
||||
);
|
||||
this.host.replaceEvents(m.id, ['chat'], rows);
|
||||
log.info(`로그 파일 채팅 ${rows.length}줄로 교체`);
|
||||
for (const row of rows) this.host.event(row);
|
||||
log.info(`로그 파일 채팅 ${rows.length}줄`);
|
||||
} catch (e) {
|
||||
log.debug('로그 파일 채팅 없음', e);
|
||||
}
|
||||
|
||||
@@ -145,8 +145,20 @@ export async function startCore(opts: CoreOptions) {
|
||||
};
|
||||
await startBot();
|
||||
|
||||
// 녹음할 서버를 바꾸면 봇을 다시 붙여 새 서버를 지켜본다 (이전 서버의 녹음은 끝난다)
|
||||
let watchedGuild = S().discord.guildId;
|
||||
const offGuild = settings.onChange((s) => {
|
||||
const g = s.discord.guildId;
|
||||
if (g === watchedGuild) return;
|
||||
watchedGuild = g;
|
||||
if (bot.state.status !== 'ready' || !g || bot.state.guild?.id === g) return;
|
||||
log.info('녹음할 서버가 바뀌어 봇을 다시 연결합니다');
|
||||
void bot.stop().then(startBot);
|
||||
});
|
||||
|
||||
const stop = async () => {
|
||||
log.info('종료 중');
|
||||
offGuild();
|
||||
relay.stop();
|
||||
retention.stop();
|
||||
games.stop();
|
||||
|
||||
@@ -21,8 +21,6 @@ export interface Settings {
|
||||
games: {
|
||||
valorant: boolean;
|
||||
lol: boolean;
|
||||
lolChatOcr: boolean;
|
||||
lolOcrRegion: { x: number; y: number; w: number; h: number };
|
||||
lolLogsDir: string | null;
|
||||
};
|
||||
stt: {
|
||||
@@ -100,8 +98,6 @@ export function defaultSettings(): Settings {
|
||||
games: {
|
||||
valorant: true,
|
||||
lol: true,
|
||||
lolChatOcr: true,
|
||||
lolOcrRegion: { x: 0.0, y: 0.6, w: 0.3, h: 0.27 },
|
||||
lolLogsDir: null,
|
||||
},
|
||||
stt: {
|
||||
|
||||
@@ -82,13 +82,15 @@ export interface GvrApi {
|
||||
adminAddUser(id: string, role: 'admin' | 'user'): Promise<{ users: AppUserRow[] }>;
|
||||
adminSetRole(id: string, role: 'admin' | 'user'): Promise<{ users: AppUserRow[] }>;
|
||||
adminRemoveUser(id: string): Promise<{ users: AppUserRow[] }>;
|
||||
adminDisplayNames(): Promise<Record<string, string>>;
|
||||
adminSetDisplayName(id: string, name: string): Promise<Record<string, string>>;
|
||||
getState(): Promise<AppState>;
|
||||
onState(cb: (s: AppState) => void): () => void;
|
||||
updateSettings(patch: DeepPartial<Settings>): Promise<Settings>;
|
||||
setSecret(key: 'botToken' | 'riotApiKey', value: string | null): Promise<void>;
|
||||
testBotToken(token?: string): Promise<{ ok: boolean; bot?: { id: string; name: string; avatar: string | null }; guilds?: { id: string; name: string }[]; error?: string }>;
|
||||
restartBot(): Promise<{ ok: boolean; error?: string }>;
|
||||
guildMembers(): Promise<{ id: string; name: string; avatar: string | null; bot: boolean }[]>;
|
||||
guildMembers(): Promise<{ id: string; name: string; avatar: string | null; bot: boolean; me: boolean; admin: boolean }[]>;
|
||||
previewTts(text: string, voice: string): Promise<{ ok: boolean; dataUrl?: string; error?: string }>;
|
||||
gpuInfo(): Promise<GpuInfo | null>;
|
||||
models(): Promise<ModelsInfo | null>;
|
||||
|
||||
@@ -122,9 +122,14 @@ export function registerIpc(ctx: IpcContext) {
|
||||
await core.startBot();
|
||||
return core.bot.state.status === 'ready' || core.bot.state.status === 'connecting' ? { ok: true } : { ok: false, error: core.bot.state.error ?? '봇을 시작하지 못했습니다' };
|
||||
},
|
||||
// 따라갈 사람 목록: 내 계정 → 관리자 → 나머지(이름순). 실패하면 오류를 그대로 보여 준다
|
||||
guildMembers: async () => {
|
||||
const ms = await core.bot.members().catch(() => []);
|
||||
return ms.map((m) => ({ id: m.id, name: m.name, avatar: m.avatar, bot: m.bot })).sort((a, b) => a.name.localeCompare(b.name, 'ko'));
|
||||
const [ms, admins] = await Promise.all([core.bot.members(), ctx.auth.adminIds().catch(() => [] as string[])]);
|
||||
const meId = ctx.auth.state.user?.id ?? null;
|
||||
const rank = (m: { me: boolean; admin: boolean }) => (m.me ? 0 : m.admin ? 1 : 2);
|
||||
return ms
|
||||
.map((m) => ({ id: m.id, name: core.store.displayNames()[m.id] ?? m.name, avatar: m.avatar, bot: m.bot, me: m.id === meId, admin: admins.includes(m.id) }))
|
||||
.sort((a, b) => rank(a) - rank(b) || a.name.localeCompare(b.name, 'ko'));
|
||||
},
|
||||
previewTts: async (text: string, voice: string) => {
|
||||
try {
|
||||
@@ -343,6 +348,13 @@ export function registerIpc(ctx: IpcContext) {
|
||||
adminAddUser: (id: string, r: 'admin' | 'user') => ctx.auth.adminAddUser(id, r),
|
||||
adminSetRole: (id: string, r: 'admin' | 'user') => ctx.auth.adminSetRole(id, r),
|
||||
adminRemoveUser: (id: string) => ctx.auth.adminRemoveUser(id),
|
||||
adminDisplayNames: () => ctx.auth.displayNames(),
|
||||
adminSetDisplayName: async (id: string, name: string) => {
|
||||
if (role() !== 'superadmin') throw new Error('표시 이름은 최고 관리자만 바꿀 수 있습니다');
|
||||
const r = await ctx.auth.adminSetDisplayName(id, name);
|
||||
ctx.current()?.core.store.setDisplayNames(r.names);
|
||||
return r.names;
|
||||
},
|
||||
openExternal: h.openExternal,
|
||||
quit: h.quit,
|
||||
};
|
||||
|
||||
@@ -228,6 +228,18 @@ const refreshShell = () => {
|
||||
|
||||
let starting: Promise<void> | null = null;
|
||||
|
||||
/** 표시 이름(실명 숨기기)을 사이트 서버에서 받아 녹음 기록 · 범인 분석에 반영한다 (못 받으면 저장해 둔 것을 그대로 쓴다) */
|
||||
async function syncNames(): Promise<void> {
|
||||
const c = core;
|
||||
if (!c || !auth?.ok) return;
|
||||
try {
|
||||
const names = await auth.displayNames();
|
||||
if (core === c) c.store.setDisplayNames(names);
|
||||
} catch (e: any) {
|
||||
log.warn(`표시 이름을 받지 못했습니다: ${e?.message ?? e}`);
|
||||
}
|
||||
}
|
||||
|
||||
/** 로그인 확인 후 코어 시작 */
|
||||
function startApp(): Promise<void> {
|
||||
if (core) return Promise.resolve();
|
||||
@@ -236,6 +248,7 @@ function startApp(): Promise<void> {
|
||||
// 겜녹이 봇 중계가 로그인 만료 · 등록 해제를 알려 오면 10분을 기다리지 않고 바로 확인해서 잠근다
|
||||
const c = await startCore({ dataDir, resourcesDir: resourcesDir(), worker: workerCommand(), version: app.getVersion(), settings: settings!, onBotUnauthorized: () => void auth?.check() });
|
||||
core = c;
|
||||
void syncNames();
|
||||
ft = new Finetuner(c, pushState);
|
||||
ft.scheduleNightly();
|
||||
appError = null;
|
||||
@@ -315,7 +328,7 @@ app.whenReady().then(async () => {
|
||||
const st = a.state.status;
|
||||
if ((st === 'ok' && Date.now() - lastCheck > 10 * 60000) || (st === 'error' && Date.now() - lastCheck > 60000) || (st === 'ok' && a.state.offline && Date.now() - lastCheck > 60000)) {
|
||||
lastCheck = Date.now();
|
||||
void a.check();
|
||||
void a.check().then(syncNames);
|
||||
}
|
||||
}, 15000);
|
||||
setInterval(() => {
|
||||
|
||||
@@ -7,7 +7,7 @@ const METHODS = [
|
||||
'runRetention', 'users', 'setRiotIds', 'setExcluded', 'dictionary', 'addWord', 'addCorrection', 'deleteDict', 'setDictEnabled',
|
||||
'finetuneStatus', 'finetuneInstall', 'finetuneStart', 'finetuneStop', 'finetuneRollback', 'clearTrainingData', 'openExternal',
|
||||
'openPath', 'setAutoStart', 'finishWizard', 'recentLogs', 'quit',
|
||||
'authState', 'authLogin', 'authCancel', 'authLogout', 'authRecheck', 'adminUsers', 'adminAddUser', 'adminSetRole', 'adminRemoveUser',
|
||||
'authState', 'authLogin', 'authCancel', 'authLogout', 'authRecheck', 'adminUsers', 'adminAddUser', 'adminSetRole', 'adminRemoveUser', 'adminDisplayNames', 'adminSetDisplayName',
|
||||
];
|
||||
const api: Record<string, unknown> = {};
|
||||
for (const m of METHODS) api[m] = (...args: unknown[]) => ipcRenderer.invoke(`gvr:${m}`, ...args);
|
||||
|
||||
@@ -25,7 +25,7 @@ function defaults(): Settings {
|
||||
ttsOnNewMember: true,
|
||||
ttsVoice: 'ko-KR-SunHiNeural',
|
||||
},
|
||||
games: { valorant: true, lol: true, lolChatOcr: true, lolOcrRegion: { x: 0.0, y: 0.6, w: 0.3, h: 0.27 }, lolLogsDir: null },
|
||||
games: { valorant: true, lol: true, lolLogsDir: null },
|
||||
stt: {
|
||||
realtimeModel: 'large-v3-turbo',
|
||||
preciseModel: 'large-v3',
|
||||
@@ -111,6 +111,7 @@ export function createMockGvr(): GvrApi {
|
||||
};
|
||||
const authListeners = new Set<(s: AuthView) => void>();
|
||||
const emitAuth = () => authListeners.forEach((l) => l(structuredClone(auth)));
|
||||
const displayNames: Record<string, string> = { '100000000000000003': '지호' };
|
||||
let adminRows: AppUserRow[] = [
|
||||
{ id: '293719842274541579', name: '사금향', avatar: null, role: 'superadmin', fixed: true, addedBy: null, addedAt: null, lastSeenAt: now - 60000, lastVersion: '1.2.0' },
|
||||
{ id: '1352267557213573160', name: '두번째관리자', avatar: null, role: 'superadmin', fixed: true, addedBy: null, addedAt: null, lastSeenAt: now - 3 * 86400000, lastVersion: '1.2.0' },
|
||||
@@ -292,6 +293,17 @@ export function createMockGvr(): GvrApi {
|
||||
adminRows = adminRows.map((u) => (u.id === id && !u.fixed ? { ...u, role: r } : u));
|
||||
return { users: structuredClone(adminRows) };
|
||||
},
|
||||
async adminDisplayNames() {
|
||||
await sleep(150);
|
||||
return { ...displayNames };
|
||||
},
|
||||
async adminSetDisplayName(id, name) {
|
||||
await sleep(150);
|
||||
adminCheck('superadmin');
|
||||
if (name.trim()) displayNames[id] = name.trim();
|
||||
else delete displayNames[id];
|
||||
return { ...displayNames };
|
||||
},
|
||||
async adminRemoveUser(id) {
|
||||
await sleep(200);
|
||||
adminCheck('superadmin');
|
||||
@@ -357,12 +369,12 @@ export function createMockGvr(): GvrApi {
|
||||
async guildMembers() {
|
||||
await sleep(300);
|
||||
return [
|
||||
{ id: 'u1', name: '민준', avatar: null, bot: false },
|
||||
{ id: 'u2', name: '서연', avatar: null, bot: false },
|
||||
{ id: 'u3', name: '지호', avatar: null, bot: false },
|
||||
{ id: 'u4', name: '현우', avatar: null, bot: false },
|
||||
{ id: 'b1', name: '겜녹이', avatar: null, bot: true },
|
||||
{ id: 'b2', name: 'MEE6', avatar: null, bot: true },
|
||||
{ id: 'u1', name: '민준', avatar: null, bot: false, me: true, admin: true },
|
||||
{ id: 'u3', name: '지호', avatar: null, bot: false, me: false, admin: true },
|
||||
{ id: 'u2', name: '서연', avatar: null, bot: false, me: false, admin: false },
|
||||
{ id: 'u4', name: '현우', avatar: null, bot: false, me: false, admin: false },
|
||||
{ id: 'b1', name: '겜녹이', avatar: null, bot: true, me: false, admin: false },
|
||||
{ id: 'b2', name: 'MEE6', avatar: null, bot: true, me: false, admin: false },
|
||||
];
|
||||
},
|
||||
async previewTts() {
|
||||
@@ -462,7 +474,6 @@ export function createMockGvr(): GvrApi {
|
||||
{ id: 'tts', label: 'TTS 안내 음성', ok: true, detail: 'Edge TTS 응답 0.6초' },
|
||||
{ id: 'valorant', label: '발로란트 로컬 API', ok: true, detail: 'Riot Client 연결됨 (lockfile)' },
|
||||
{ id: 'lol', label: '롤 Live Client API', ok: null, detail: '게임이 꺼져 있어 확인할 수 없습니다' },
|
||||
{ id: 'ocr', label: '롤 채팅 OCR', ok: null, detail: '게임이 꺼져 있어 확인할 수 없습니다' },
|
||||
{ id: 'relay', label: '사이트 서버', ok: state.relay.state === 'online', detail: state.relay.state === 'online' ? 'gvr.tkrmagid.kr 연결됨 · 왕복 38ms' : '등록되지 않음' },
|
||||
{ id: 'disk', label: '저장 공간', ok: true, detail: 'D: 여유 412GB' },
|
||||
];
|
||||
|
||||
@@ -178,8 +178,6 @@ input[type='number'].input { flex: none; padding: 7px 8px; }
|
||||
.game.lol.on { border: 2px solid var(--lol); background: linear-gradient(160deg, #241e13, var(--panel) 60%); padding: 15px 17px; }
|
||||
.game.lol .game-name { color: var(--lol); }
|
||||
.game.lol .tg.on { background: linear-gradient(180deg, #c8aa6e, #9a7b45); }
|
||||
.region { display: flex; gap: 10px; }
|
||||
.region label { display: flex; align-items: center; gap: 5px; }
|
||||
|
||||
/* 표 */
|
||||
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
||||
|
||||
@@ -150,6 +150,66 @@ function UserTable({ users, superAdmin, onChange }: { users: AppUserRow[]; super
|
||||
);
|
||||
}
|
||||
|
||||
/** 표시 이름: 실명이 들어간 디스코드 이름 · 서버 별명 대신 사이트 · 녹음 기록 · 범인 분석에 쓸 이름 */
|
||||
function DisplayNames({ superAdmin }: { superAdmin: boolean }) {
|
||||
const { toast } = useApp();
|
||||
const list = useLoad(() => gvr.adminDisplayNames());
|
||||
const [id, setId] = useState('');
|
||||
const [name, setName] = useState('');
|
||||
const act = useAction();
|
||||
const valid = /^\d{17,20}$/.test(id.trim()) && !!name.trim();
|
||||
const save = async (uid: string, n: string) => {
|
||||
const r = await act.run(() => gvr.adminSetDisplayName(uid, n));
|
||||
if (r) {
|
||||
list.setData(r);
|
||||
toast(n ? `${uid} → ${n}` : `${uid} 표시 이름 지움`);
|
||||
setId('');
|
||||
setName('');
|
||||
}
|
||||
};
|
||||
const rows = Object.entries(list.data ?? {});
|
||||
return (
|
||||
<>
|
||||
{superAdmin && (
|
||||
<div className="field">
|
||||
<input className="input mono" value={id} placeholder="디스코드 아이디" spellCheck={false} onChange={(e) => setId(e.target.value.replace(/\s/g, ''))} />
|
||||
<input className="input" value={name} placeholder="보일 이름" maxLength={32} onChange={(e) => setName(e.target.value)} onKeyDown={(e) => e.key === 'Enter' && valid && void save(id.trim(), name.trim())} />
|
||||
<Btn primary disabled={!valid} busy={act.busy} onClick={() => save(id.trim(), name.trim())}>
|
||||
저장
|
||||
</Btn>
|
||||
</div>
|
||||
)}
|
||||
{list.loading && !list.data ? (
|
||||
<Spinner />
|
||||
) : list.error ? (
|
||||
<Err>{list.error}</Err>
|
||||
) : rows.length ? (
|
||||
<table className="table">
|
||||
<tbody>
|
||||
{rows.map(([uid, n]) => (
|
||||
<tr key={uid}>
|
||||
<td className="mono small">{uid}</td>
|
||||
<td>{n}</td>
|
||||
{superAdmin && (
|
||||
<td className="r">
|
||||
<Btn small ghost disabled={act.busy} onClick={() => save(uid, '')}>
|
||||
지우기
|
||||
</Btn>
|
||||
</td>
|
||||
)}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
) : (
|
||||
<div className="muted">정해 둔 표시 이름이 없습니다. 디스코드 이름(서버 별명)이 그대로 보입니다.</div>
|
||||
)}
|
||||
<div className="hint">디스코드 이름이나 서버 별명에 실명이 들어 있으면 여기서 다른 이름을 정해 주세요. 사이트, 녹음 기록, 범인 분석에 이 이름만 쓰고 이미 저장된 기록의 이름도 바꿉니다.</div>
|
||||
<Err>{act.error}</Err>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminTab() {
|
||||
const { state } = useApp();
|
||||
const superAdmin = state.account.role === 'superadmin';
|
||||
@@ -179,6 +239,9 @@ export function AdminTab() {
|
||||
>
|
||||
{list.loading && !list.data ? <Spinner /> : list.error ? <Err>{list.error}</Err> : <UserTable users={users} superAdmin={superAdmin} onChange={set} />}
|
||||
</Section>
|
||||
<Section title="표시 이름 (실명 숨기기)" sub="바꾸기는 최고 관리자만">
|
||||
<DisplayNames superAdmin={superAdmin} />
|
||||
</Section>
|
||||
<Section title="관리자 전용 기능" sub="일반 유저 화면에서는 잠겨 있습니다">
|
||||
<ul className="admin-list">
|
||||
{ADMIN_FEATURES.map((f) => (
|
||||
|
||||
@@ -220,13 +220,20 @@ export function GuildFollow({ guilds, compact }: { guilds?: { id: string; name:
|
||||
disabled={!d.guildId || members.loading}
|
||||
options={[
|
||||
{ value: '', label: members.loading && d.guildId ? '불러오는 중…' : '선택 안 함' },
|
||||
...people.map((m) => ({ value: m.id, label: m.name })),
|
||||
...people.map((m) => ({ value: m.id, label: m.me ? `${m.name} (나)` : m.admin ? `${m.name} · 관리자` : m.name })),
|
||||
...(d.followUserId && !people.some((p) => p.id === d.followUserId) && !members.loading ? [{ value: d.followUserId, label: `(알 수 없음 ${d.followUserId})` }] : []),
|
||||
]}
|
||||
onChange={(v) => save({ discord: { followUserId: v || null } })}
|
||||
/>
|
||||
</Line>
|
||||
{members.error && <Err>{members.error}</Err>}
|
||||
{members.error && (
|
||||
<Err>
|
||||
멤버 목록을 불러오지 못했습니다: {members.error}{' '}
|
||||
<Btn small onClick={() => void members.reload()}>
|
||||
다시 불러오기
|
||||
</Btn>
|
||||
</Err>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState } from 'react';
|
||||
import type { User } from '@gvr/shared';
|
||||
import { gvr, useAction, useApp, useLoad } from '../store';
|
||||
import { Avatar, Btn, Dot, Err, FolderRow, Line, NumInput, Page, Section, Spinner, Toggle, ToggleLine } from '../ui';
|
||||
import { Avatar, Btn, Dot, Err, FolderRow, Page, Section, Spinner, Toggle } from '../ui';
|
||||
|
||||
/** 발로란트 / 롤 켜기 카드 (마법사에서도 사용) */
|
||||
export function GameCards({ showStatus = true }: { showStatus?: boolean }) {
|
||||
@@ -9,7 +9,7 @@ export function GameCards({ showStatus = true }: { showStatus?: boolean }) {
|
||||
const g = settings.games;
|
||||
const cards = [
|
||||
{ id: 'valorant' as const, name: 'VALORANT', ko: '발로란트', desc: '라운드 · 킬 · 스파이크 이벤트와 대화를 함께 기록', on: g.valorant, st: state.games.valorant },
|
||||
{ id: 'lol' as const, name: 'League of Legends', ko: '리그 오브 레전드', desc: '킬 · 오브젝트 · 채팅(OCR)과 대화를 함께 기록', on: g.lol, st: state.games.lol },
|
||||
{ id: 'lol' as const, name: 'League of Legends', ko: '리그 오브 레전드', desc: '킬 · 오브젝트 · 채팅(API)과 대화를 함께 기록', on: g.lol, st: state.games.lol },
|
||||
];
|
||||
return (
|
||||
<div className="games">
|
||||
@@ -143,23 +143,14 @@ export function GamesTab() {
|
||||
const { settings, save } = useApp();
|
||||
const g = settings.games;
|
||||
const users = useLoad(() => gvr.users());
|
||||
const region = g.lolOcrRegion;
|
||||
return (
|
||||
<Page title="게임 연동">
|
||||
<GameCards />
|
||||
<Section title="리그 오브 레전드 세부 설정" className={g.lol ? '' : 'disabled'}>
|
||||
<ToggleLine label="롤 채팅 OCR" hint="게임 옵션에서 채팅 타임스탬프를 켜고 '테두리 없음' 창 모드를 쓰면 정확합니다" on={g.lolChatOcr} onChange={(v) => save({ games: { lolChatOcr: v } })} />
|
||||
<Line label="채팅 영역" hint="화면 크기에 대한 비율 (0~1) · 왼쪽 아래 채팅창 기본값">
|
||||
<div className="region">
|
||||
{(['x', 'y', 'w', 'h'] as const).map((k) => (
|
||||
<label key={k}>
|
||||
<span className="muted mono">{k}</span>
|
||||
<NumInput value={region[k]} min={0} max={1} step={0.01} width={70} onCommit={(n) => save({ games: { lolOcrRegion: { ...region, [k]: n } } })} />
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</Line>
|
||||
<div className="lab" style={{ marginTop: 8 }}>
|
||||
<div className="muted" style={{ marginBottom: 8 }}>
|
||||
롤 채팅은 롤 클라이언트(LCU) API 로 챔피언 선택 · 게임 후 채팅을 받습니다. 게임 중 전체 · 팀 채팅은 롤이 API 로 주지 않아, 게임 로그 파일에 남아 있을 때만 경기 뒤에 붙입니다. 화면 글자 인식(OCR)은 쓰지 않습니다.
|
||||
</div>
|
||||
<div className="lab">
|
||||
롤 로그 폴더 <span className="dim">(비워 두면 Riot Games 기본 위치에서 찾습니다)</span>
|
||||
</div>
|
||||
<FolderRow
|
||||
|
||||
@@ -63,7 +63,7 @@ function Step2() {
|
||||
<>
|
||||
<Head title="게임 선택" desc="켠 게임의 경기 이벤트(킬 · 라운드 · 오브젝트)를 대화 기록과 같은 시간축에 함께 남깁니다. 나중에 게임 연동 탭에서 바꿀 수 있습니다." />
|
||||
<GameCards showStatus={false} />
|
||||
<div className="hint">롤은 채팅 OCR(화면 글자 읽기)도 함께 씁니다. 게임 옵션에서 채팅 타임스탬프를 켜고 '테두리 없음' 창 모드를 쓰면 정확합니다.</div>
|
||||
<div className="hint">롤 채팅은 롤 클라이언트 API 로 받습니다 (챔피언 선택 · 게임 후 채팅). 화면 글자 인식(OCR)은 쓰지 않습니다.</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user