Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { BskyAgent } = require('@atproto/api');
- const fs = require('fs');
- const identifier = 'KULLANICIADI.bsky.social'; // BlueSky kullanıcı adın
- const password = 'SIFRE'; // Bluesky şifren
- const agent = new BskyAgent({ service: 'https://bsky.social' });
- // Rate limit korumalı unfollow fonksiyonu
- const tryDeleteFollow = async (uri, handle, retries = 3) => {
- for (let i = 0; i < retries; i++) {
- try {
- await agent.deleteFollow(uri); // Doğru metod: deleteFollow
- console.log(`✅ ${handle} takipten çıkarıldı.`);
- return;
- } catch (err) {
- if (err.status === 429) {
- console.warn(`⏳ Rate limit yedik. Bekliyoruz... (${i + 1}/${retries})`);
- await sleep(5000);
- } else {
- console.warn(`❌ ${handle} için hata: ${err.message}`);
- return;
- }
- }
- }
- };
- function sleep(ms) {
- return new Promise(resolve => setTimeout(resolve, ms));
- }
- async function findAndUnfollowNonFollowers() {
- try {
- await agent.login({ identifier, password });
- const myDid = agent.session.did;
- console.log("✅ Giriş başarılı! DID:", myDid);
- // Takip ettiklerini al (DID bazında karşılaştırma için)
- let follows = [];
- let cursor = null;
- do {
- const res = await agent.getFollows({ actor: myDid, limit: 100, cursor });
- follows.push(...res.data.follows);
- cursor = res.data.cursor;
- } while (cursor);
- console.log(`📋 Takip ettiğin kişi sayısı: ${follows.length}`);
- // Takip edenleri al
- let followers = [];
- cursor = null;
- do {
- const res = await agent.getFollowers({ actor: myDid, limit: 100, cursor });
- followers.push(...res.data.followers.map(f => f.did));
- cursor = res.data.cursor;
- } while (cursor);
- console.log(`📥 Seni takip eden kişi sayısı: ${followers.length}`);
- // Seni takip etmeyenleri bul
- const nonFollowers = follows.filter(person => !followers.includes(person.did));
- // Takip kayıtlarının URI'larını al
- const followRecords = [];
- cursor = null;
- do {
- const res = await agent.api.com.atproto.repo.listRecords({
- repo: myDid,
- collection: 'app.bsky.graph.follow',
- limit: 100,
- cursor
- });
- followRecords.push(...res.data.records);
- cursor = res.data.cursor;
- } while (cursor);
- // DID -> URI eşleşmesini hazırla
- const followMap = new Map();
- followRecords.forEach(record => {
- followMap.set(record.value.subject, record.uri); // subject: takip edilen kişinin DID'i
- });
- const filePath = 'nonFollowers.txt';
- let output = "🚫 Seni Takip Etmeyen Kişiler:\n ✅ muhammetsirin.bluesky.social'ı takip etmeyi unutma!\n\n";
- let count = 0;
- for (const person of nonFollowers) {
- output += `- ${person.handle}\n`;
- const followUri = followMap.get(person.did);
- if (followUri) {
- await tryDeleteFollow(followUri, person.handle);
- count++;
- await sleep(1500); // Rate limit koruması
- } else {
- console.warn(`⚠️ ${person.handle} için URI bulunamadı.`);
- }
- if (count % 50 === 0 && count !== 0) {
- console.log("⏸️ 50 kişi işlendi, 10 saniye mola...");
- await sleep(10000);
- }
- }
- // Sonuç dosyaya yazma
- fs.writeFileSync(filePath, output);
- console.log(`✅ "${filePath}" dosyasına yazıldı.`);
- console.log(`✅ Toplam takipten çıkarılan kişi sayısı: ${count}`);
- console.log(`💌 Kod için bir teşekkürü unutma: @muhammetsirin.bsky.social`);
- } catch (error) {
- console.error("❌ Bir hata oluştu:", error.message);
- }
- }
- findAndUnfollowNonFollowers();
Advertisement
Add Comment
Please, Sign In to add comment