Add relay profile switching

This commit is contained in:
2026-07-31 21:53:43 +09:00
parent 67ee53c305
commit 079aaa1664
18 changed files with 413 additions and 12 deletions
+8 -4
View File
@@ -1,13 +1,17 @@
import { TwitterClient } from '@yuta/bird'
import type { BirdReader } from './post-service'
let client: TwitterClient | undefined
const clients = new Map<string | undefined, TwitterClient>()
export function getBirdReader(): BirdReader {
client ??= new TwitterClient({
export function getBirdReader(profileName?: string): BirdReader {
const existing = clients.get(profileName)
if (existing) return existing
const client = new TwitterClient({
relayBaseUrl: process.env.TWITTER_RELAY_BASE_URL,
profileName: process.env.BIRD_PROFILE_NAME,
profileName,
timeoutMs: 20_000,
})
clients.set(profileName, client)
return client
}