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:
EJClaw
2026-10-16 02:42:57 +09:00
parent 7db2a5d69f
commit b230443409
94 changed files with 494 additions and 677 deletions

View File

@@ -95,7 +95,7 @@ export function registerAppAuth(
p.result = { state: 'error', error: '디스코드 로그인에 실패했습니다. 다시 시도해 주세요' };
return page(reply, 502, '디스코드 로그인 실패', '잠시 뒤 겜녹이 앱에서 다시 시도해 주세요.');
}
const user: AppUserInfo = { id: u.id, name: u.global_name || u.username, avatar: avatarUrl(u) };
const user: AppUserInfo = { id: u.id, name: store.nameOf(u.id, u.global_name || u.username), avatar: avatarUrl(u) };
const role = roleOf(u.id);
if (!role) {
log.info({ user: u.id }, '앱 로그인 거절: 등록되지 않은 아이디');
@@ -173,6 +173,30 @@ export function registerAppAuth(
};
const role = (v: unknown): 'admin' | 'user' | null => (v === 'admin' || v === 'user' ? v : null);
// 관리자 아이디 (등록된 유저 누구나): 앱의 따라갈 사람 목록에서 관리자를 위에 보여 준다
app.get('/app/admins', async (req, reply) => {
if (!(await auth(req, reply))) return;
const ids = new Set(cfg.superAdmins);
for (const u of store.appUsers()) if (u.role === 'admin') ids.add(u.id);
return { ids: [...ids] };
});
// 표시 이름 (실명 숨기기): 등록된 유저는 누구나 받아 앱의 녹음 기록 · 멤버 목록에 쓴다. 바꾸기는 최고 관리자만
app.get('/app/names', async (req, reply) => {
if (!(await auth(req, reply))) return;
return { names: store.displayNames() };
});
app.put<{ Body: { id?: string; name?: string | null } }>('/app/admin/names', async (req, reply) => {
const a = await need(req, reply, 'superadmin');
if (!a) return;
const id = String(req.body?.id ?? '').trim();
const name = String(req.body?.name ?? '').trim().slice(0, 32);
if (!SNOWFLAKE.test(id)) return reply.code(400).send({ error: 'bad_id', message: '디스코드 아이디는 17~20자리 숫자입니다' });
store.setDisplayName(id, name || null);
req.log.info({ by: a.id, user: id, set: !!name }, '표시 이름 변경');
return { names: store.displayNames() };
});
app.get('/app/admin/users', async (req, reply) => {
if (!(await need(req, reply, 'admin'))) return;
return { users: rows() };

View File

@@ -268,7 +268,8 @@ export class BotBroker {
return;
}
case 'req': {
if (m.op !== 'members' || m.guildId !== c.guildId) return this.send(c, { t: 'res', id: m.id, ok: false, error: 'forbidden' });
// 지켜보기 전이어도 받을 수 있다 (가입한 서버인지는 source.members 가 확인한다)
if (m.op !== 'members' || !SNOWFLAKE.test(String(m.guildId))) return this.send(c, { t: 'res', id: m.id, ok: false, error: 'forbidden' });
this.source.members(m.guildId, c.userId).then(
(data) => this.send(c, { t: 'res', id: m.id, ok: true, data }),
(e) => this.send(c, { t: 'res', id: m.id, ok: false, error: String(e?.message ?? e) }),

View File

@@ -12,8 +12,12 @@ if (cmd === 'code') {
console.log(JSON.stringify(store.device(), (k, v) => (k === 'keyHash' ? undefined : v), 2));
} else if (cmd === 'unregister') {
console.log(`등록 해제: ${store.removeDevices()}대 (서버를 다시 시작하면 연결도 끊긴다)`);
} else if (cmd === 'name' && /^\d{17,20}$/.test(process.argv[3] ?? '')) {
// 표시 이름 (실명 숨기기). 서버가 떠 있으면 서버가 덮어쓸 수 있으니 컨테이너를 멈춘 상태에서 쓴다 (평소에는 앱 관리자 탭)
store.setDisplayName(process.argv[3]!, process.argv.slice(4).join(' ').trim() || null);
console.log(JSON.stringify(store.displayNames()));
} else {
console.log('사용법: node dist/cli.js code [분] | device | unregister');
console.log('사용법: node dist/cli.js code [분] | device | unregister | name <디스코드 아이디> [표시 이름]');
}
store.flush();

View File

@@ -46,6 +46,8 @@ interface Data {
appSessions: AppSession[];
/** 최고 관리자의 마지막 접속 (appUsers 에 없을 수 있어 따로 둔다) */
appSeen: Record<string, { at: number; version: string | null; name: string; avatar: string | null }>;
/** 디스코드 아이디 → 사이트 · 앱에 보일 이름 (실명이 들어간 디스코드 이름 · 서버 별명 대신 쓴다) */
displayNames: Record<string, string>;
}
// codes 는 server.json 에 두지 않는다 (codes.json)
@@ -68,7 +70,7 @@ export class ServerStore {
try {
this.d = JSON.parse(fs.readFileSync(this.file, 'utf8'));
} catch {
this.d = { devices: [], codes: [], sessions: [], appUsers: [], appSessions: [], appSeen: {} };
this.d = { devices: [], codes: [], sessions: [], appUsers: [], appSessions: [], appSeen: {}, displayNames: {} };
}
this.d.devices ||= [];
this.d.sessions ||= [];
@@ -83,6 +85,7 @@ export class ServerStore {
this.d.appUsers ||= [];
this.d.appSessions ||= [];
this.d.appSeen ||= {};
this.d.displayNames ||= {};
if (migrated) this.save(true);
}
@@ -165,7 +168,7 @@ export class ServerStore {
/** 새 세션. token 은 쿠키에만 넣고, 서버에는 해시(id)만 남는다 */
createSession(user: Session['user'], ttlMs = 30 * 24 * 3600 * 1000): Session & { token: string } {
const token = crypto.randomBytes(24).toString('base64url');
const s: Session = { id: sha256(token), hashed: true, user, createdAt: Date.now(), checkedAt: Date.now(), expiresAt: Date.now() + ttlMs };
const s: Session = { id: sha256(token), hashed: true, user: { ...user, name: this.nameOf(user.id, user.name) }, createdAt: Date.now(), checkedAt: Date.now(), expiresAt: Date.now() + ttlMs };
this.d.sessions = this.d.sessions.filter((x) => x.expiresAt > Date.now());
this.d.sessions.push(s);
this.save();
@@ -190,6 +193,26 @@ export class ServerStore {
this.save();
}
// ---- 표시 이름 (실명 숨기기)
/** 정해 둔 표시 이름이 있으면 그것, 없으면 디스코드에서 받은 이름 */
nameOf(id: string, discordName: string): string {
return this.d.displayNames[id] ?? discordName;
}
displayNames(): Record<string, string> {
return { ...this.d.displayNames };
}
/** 표시 이름을 정하거나(name) 지운다(null). 이미 저장된 세션 · 앱 유저 이름도 바로 바꿔 예전 이름을 남기지 않는다 */
setDisplayName(id: string, name: string | null): void {
if (name) {
this.d.displayNames[id] = name;
for (const s of this.d.sessions) if (s.user.id === id) s.user.name = name;
const u = this.appUser(id);
if (u) u.name = name;
if (this.d.appSeen[id]) this.d.appSeen[id].name = name;
} else delete this.d.displayNames[id];
this.save(true);
}
// ---- 앱 유저 등록 · 앱 로그인 토큰
appUsers(): AppUser[] {
return this.d.appUsers;
@@ -199,6 +222,7 @@ export class ServerStore {
}
upsertAppUser(u: Pick<AppUser, 'id' | 'name' | 'avatar' | 'role' | 'addedBy'>): AppUser {
const cur = this.appUser(u.id);
u = { ...u, name: this.nameOf(u.id, u.name) };
if (cur) {
Object.assign(cur, { name: u.name, avatar: u.avatar, role: u.role });
this.save(true);
@@ -228,7 +252,7 @@ export class ServerStore {
}
touchAppUser(id: string, seen: { version: string | null; name: string; avatar: string | null }): void {
const at = Date.now();
this.d.appSeen[id] = { at, ...seen };
this.d.appSeen[id] = { at, ...seen, name: this.nameOf(id, seen.name) };
const u = this.appUser(id);
if (u) {
u.lastSeenAt = at;