import { MastodonBridge } from './lib/bridge.js'
import { MastodonClient } from './lib/mastodon-client.js'
import { KeetClient } from './lib/keet-client.js'
import { Router } from './lib/router.js'
import { statusToEnvelope, keetToMastodon, envelopeToStatusText, statusToKeetText, stripHtml } from './lib/adapter.js'
export {
MastodonBridge,
MastodonClient,
KeetClient,
Router,
statusToEnvelope,
keetToMastodon,
envelopeToStatusText,
statusToKeetText,
stripHtml
}
// CLI entry point
const args = process.argv.slice(2)
if (args.includes('--help') || args.includes('-h')) {
console.log(`bridge-mastodon — Mastodon ↔ Keet bridge
Usage:
bridge-mastodon --instance <host> --token <token> --keet-room <roomId> [options]
Options:
--instance <host> Mastodon instance (e.g. mastodon.social)
--token <token> Mastodon access token (or MASTODON_TOKEN env)
--keet-room <roomId> Keet room ID to bridge
--keet-port <port> Keet daemon port (default: 3117)
--visibility <vis> Post visibility: public, unlisted, private, direct (default: unlisted)
--tag <hashtag> Filter: only bridge posts with this hashtag
--help Show this help`)
process.exit(0)
}
function getArg (flag) {
const idx = args.indexOf(flag)
return idx !== -1 ? args[idx + 1] : null
}
const instance = getArg('--instance')
const token = getArg('--token') || process.env.MASTODON_TOKEN
const roomId = getArg('--keet-room')
const keetPort = parseInt(getArg('--keet-port') || '3117', 10)
const visibility = getArg('--visibility') || 'unlisted'
const tag = getArg('--tag')
if (instance && token && roomId) {
const bridge = new MastodonBridge({
instance,
token,
roomId,
keetPort,
visibility,
tag,
onLog: (msg) => console.log(`[mastodon-bridge] ${msg}`)
})
bridge.start().catch(err => {
console.error('Bridge failed to start:', err.message)
process.exit(1)
})
process.on('SIGINT', () => {
bridge.stop()
process.exit(0)
})
}