Advertisement
Guest User

Untitled

a guest
Sep 7th, 2024
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { BskyAgent } from '@atproto/api';
  2. import { argv } from 'node:process';
  3.  
  4. const agent = new BskyAgent({ service: 'https://bsky.social' });
  5.  
  6. await agent.login({
  7.     identifier: argv[2],
  8.     password: argv[3],
  9. });
  10.  
  11. let cursor = undefined;
  12.  
  13. const followers = [];
  14.  
  15. do {
  16.     const data = await agent.getFollowers({ actor: agent.session.did, cursor, limit: 100 });
  17.     cursor = data.data.cursor;
  18.     followers.push(...data.data.followers);
  19. } while (cursor);
  20.  
  21. const facets = followers.map(v => { return {
  22.     $type: 'app.bsky.richtext.facet',
  23.     index: { byteStart: 0, byteEnd: 0 },
  24.     features: [{
  25.         '$type': 'app.bsky.richtext.facet#mention',
  26.         did: v.did,
  27.     }],
  28. } });
  29.  
  30. const text = '...';
  31.  
  32. await agent.post({
  33.     text,
  34.     facets,
  35.     langs: ['en'],
  36.     createdAt: new Date().toISOString(),
  37. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement