Guest User

Untitled

a guest
Apr 5th, 2025
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | Source Code | 0 0
  1. const { BskyAgent } = require('@atproto/api');
  2. const fs = require('fs');
  3.  
  4. const identifier = 'KULLANICIADI.bsky.social'; // BlueSky kullanıcı adın
  5. const password = 'SIFRE'; // Bluesky şifren
  6.  
  7. const agent = new BskyAgent({ service: 'https://bsky.social' });
  8.  
  9. // Rate limit korumalı unfollow fonksiyonu
  10. const tryDeleteFollow = async (uri, handle, retries = 3) => {
  11. for (let i = 0; i < retries; i++) {
  12. try {
  13. await agent.deleteFollow(uri); // Doğru metod: deleteFollow
  14. console.log(`✅ ${handle} takipten çıkarıldı.`);
  15. return;
  16. } catch (err) {
  17. if (err.status === 429) {
  18. console.warn(`⏳ Rate limit yedik. Bekliyoruz... (${i + 1}/${retries})`);
  19. await sleep(5000);
  20. } else {
  21. console.warn(`❌ ${handle} için hata: ${err.message}`);
  22. return;
  23. }
  24. }
  25. }
  26. };
  27.  
  28. function sleep(ms) {
  29. return new Promise(resolve => setTimeout(resolve, ms));
  30. }
  31.  
  32. async function findAndUnfollowNonFollowers() {
  33. try {
  34. await agent.login({ identifier, password });
  35.  
  36. const myDid = agent.session.did;
  37. console.log("✅ Giriş başarılı! DID:", myDid);
  38.  
  39. // Takip ettiklerini al (DID bazında karşılaştırma için)
  40. let follows = [];
  41. let cursor = null;
  42. do {
  43. const res = await agent.getFollows({ actor: myDid, limit: 100, cursor });
  44. follows.push(...res.data.follows);
  45. cursor = res.data.cursor;
  46. } while (cursor);
  47.  
  48. console.log(`📋 Takip ettiğin kişi sayısı: ${follows.length}`);
  49.  
  50. // Takip edenleri al
  51. let followers = [];
  52. cursor = null;
  53. do {
  54. const res = await agent.getFollowers({ actor: myDid, limit: 100, cursor });
  55. followers.push(...res.data.followers.map(f => f.did));
  56. cursor = res.data.cursor;
  57. } while (cursor);
  58.  
  59. console.log(`📥 Seni takip eden kişi sayısı: ${followers.length}`);
  60.  
  61. // Seni takip etmeyenleri bul
  62. const nonFollowers = follows.filter(person => !followers.includes(person.did));
  63.  
  64. // Takip kayıtlarının URI'larını al
  65. const followRecords = [];
  66. cursor = null;
  67. do {
  68. const res = await agent.api.com.atproto.repo.listRecords({
  69. repo: myDid,
  70. collection: 'app.bsky.graph.follow',
  71. limit: 100,
  72. cursor
  73. });
  74. followRecords.push(...res.data.records);
  75. cursor = res.data.cursor;
  76. } while (cursor);
  77.  
  78. // DID -> URI eşleşmesini hazırla
  79. const followMap = new Map();
  80. followRecords.forEach(record => {
  81. followMap.set(record.value.subject, record.uri); // subject: takip edilen kişinin DID'i
  82. });
  83.  
  84. const filePath = 'nonFollowers.txt';
  85. let output = "🚫 Seni Takip Etmeyen Kişiler:\n ✅ muhammetsirin.bluesky.social'ı takip etmeyi unutma!\n\n";
  86. let count = 0;
  87.  
  88. for (const person of nonFollowers) {
  89. output += `- ${person.handle}\n`;
  90.  
  91. const followUri = followMap.get(person.did);
  92.  
  93. if (followUri) {
  94. await tryDeleteFollow(followUri, person.handle);
  95. count++;
  96. await sleep(1500); // Rate limit koruması
  97. } else {
  98. console.warn(`⚠️ ${person.handle} için URI bulunamadı.`);
  99. }
  100.  
  101. if (count % 50 === 0 && count !== 0) {
  102. console.log("⏸️ 50 kişi işlendi, 10 saniye mola...");
  103. await sleep(10000);
  104. }
  105. }
  106.  
  107. // Sonuç dosyaya yazma
  108. fs.writeFileSync(filePath, output);
  109. console.log(`✅ "${filePath}" dosyasına yazıldı.`);
  110. console.log(`✅ Toplam takipten çıkarılan kişi sayısı: ${count}`);
  111. console.log(`💌 Kod için bir teşekkürü unutma: @muhammetsirin.bsky.social`);
  112.  
  113. } catch (error) {
  114. console.error("❌ Bir hata oluştu:", error.message);
  115. }
  116. }
  117.  
  118. findAndUnfollowNonFollowers();
Advertisement
Add Comment
Please, Sign In to add comment