Created
November 13, 2024 13:53
-
-
Save bmschmidt/bcd91b7b2e3bd20349b06e573a8a6bd9 to your computer and use it in GitHub Desktop.
English firehose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Firehose } from '@skyware/firehose'; | |
const firehose = new Firehose({ relay: 'wss://bsky.network' }); | |
const queue = []; | |
firehose.on('commit', (message) => { | |
for (const op of message.ops) { | |
if (!op.record) { | |
continue; | |
} | |
if (!op.record?.text) { | |
continue; | |
} | |
if (!op.record?.langs?.includes('en')) { | |
continue; | |
} | |
queue.push(op); | |
const uri = 'at://' + message.repo + '/' + op.path; | |
console.log('Operation:', JSON.stringify(op)); | |
} | |
}); | |
firehose.start(); | |
setInterval(() => { | |
const all = queue.map((c) => { | |
JSON.stringify(c); | |
}); | |
console.log(all.join('\n') + '\n'); | |
queue.length = 0; | |
}, 500); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks suspciously like I'm double logging here doesn't it?