Add relay profile switching
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user