consent-recorder: let each consenter pick which servers to record in
The site lists only servers the bot and the user share (single-member REST fetch, no privileged intent). Consent requires at least one server; the choice can be changed later and removed servers stop recording at once. Consent text mentions the server choice, so CONSENT_VERSION is bumped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -35,7 +35,7 @@ export class FollowBot {
|
||||
// 누가 봇을 끊거나 다른 채널로 옮김: 정리하고 다시 판단 (동의자가 있는 채널로 돌아감)
|
||||
const rec = this.recorders.get(newS.guild.id);
|
||||
if (newS.id === me && rec && newS.channelId !== rec.channelId) this.drop(newS.guild.id);
|
||||
if (newS.id === me || this.store.isConsented(newS.id) || this.recorders.has(newS.guild.id)) {
|
||||
if (newS.id === me || this.store.isConsentedIn(newS.id, newS.guild.id) || this.recorders.has(newS.guild.id)) {
|
||||
if (oldS.channelId && oldS.channelId !== newS.channelId) this.recorders.get(oldS.guild.id)?.stopUser(newS.id);
|
||||
this.schedule(newS.guild, newS.id);
|
||||
}
|
||||
@@ -53,9 +53,9 @@ export class FollowBot {
|
||||
await this.client.destroy();
|
||||
}
|
||||
|
||||
/** 사이트에서 동의 · 철회한 직후: 그 사람이 있는 서버를 바로 다시 판단 */
|
||||
/** 사이트에서 동의 · 철회 · 녹음할 서버를 바꾼 직후: 그 사람이 있는 서버를 바로 다시 판단 */
|
||||
consentChanged(userId: string): void {
|
||||
for (const r of this.recorders.values()) if (!this.store.isConsented(userId)) r.stopUser(userId);
|
||||
for (const [gid, r] of this.recorders) if (!this.store.isConsentedIn(userId, gid)) r.stopUser(userId);
|
||||
for (const g of this.client.guilds.cache.values()) {
|
||||
if (g.voiceStates.cache.get(userId)?.channelId || this.recorders.has(g.id)) this.schedule(g, userId);
|
||||
}
|
||||
@@ -66,6 +66,20 @@ export class FollowBot {
|
||||
for (const r of this.recorders.values()) r.stopUser(userId);
|
||||
}
|
||||
|
||||
/** 봇이 들어가 있고 이 사람도 들어가 있는 서버 (사이트에서 녹음할 서버로 고를 수 있는 곳) */
|
||||
async userGuilds(userId: string): Promise<{ id: string; name: string }[]> {
|
||||
const guilds = [...this.client.guilds.cache.values()].filter((g) => this.allowedGuild(g));
|
||||
const found = await Promise.all(
|
||||
guilds.map((g) =>
|
||||
g.members.fetch(userId).then(
|
||||
() => ({ id: g.id, name: g.name }),
|
||||
() => null, // 이 서버에 없는 사람 (Unknown Member)
|
||||
),
|
||||
),
|
||||
);
|
||||
return found.filter((g): g is { id: string; name: string } => !!g).sort((a, b) => a.name.localeCompare(b.name, 'ko'));
|
||||
}
|
||||
|
||||
/** 이 사람을 지금 녹음 중인 채널 이름 */
|
||||
recordingNow(userId: string): string | null {
|
||||
for (const [gid, r] of this.recorders) {
|
||||
@@ -101,7 +115,7 @@ export class FollowBot {
|
||||
const out: Presence[] = [];
|
||||
for (const vs of guild.voiceStates.cache.values()) {
|
||||
if (!vs.channelId || vs.id === this.client.user?.id || vs.member?.user.bot) continue;
|
||||
if (!this.store.isConsented(vs.id)) continue;
|
||||
if (!this.store.isConsentedIn(vs.id, guild.id)) continue;
|
||||
const ch = vs.channel;
|
||||
if (ch && (ch.id === current || this.canJoin(ch))) out.push({ userId: vs.id, channelId: vs.channelId });
|
||||
}
|
||||
@@ -138,7 +152,7 @@ export class FollowBot {
|
||||
}
|
||||
this.watch(guild, conn);
|
||||
const rec = new Recorder(this.store, this.cfg.dataDir, conn, guild.id, ch.id, (uid) => {
|
||||
return guild.voiceStates.cache.get(uid)?.channelId === ch.id && this.store.isConsented(uid);
|
||||
return guild.voiceStates.cache.get(uid)?.channelId === ch.id && this.store.isConsentedIn(uid, guild.id);
|
||||
});
|
||||
this.recorders.set(guild.id, rec);
|
||||
this.updatePresence();
|
||||
|
||||
Reference in New Issue
Block a user