Skip to content

Instantly share code, notes, and snippets.

@bmschmidt
Created November 13, 2024 13:53
Show Gist options
  • Save bmschmidt/bcd91b7b2e3bd20349b06e573a8a6bd9 to your computer and use it in GitHub Desktop.
Save bmschmidt/bcd91b7b2e3bd20349b06e573a8a6bd9 to your computer and use it in GitHub Desktop.
English firehose
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);
@bmschmidt
Copy link
Author

Looks suspciously like I'm double logging here doesn't it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment