Follow users in whole network instance of pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

34 lines
1.4 KiB

'use strict'
const requestsync = require('sync-request'),
url = process.argv[2] || 'https://user:pass@social.hatthieves.es'
try {
let actors,
followed = []
do {
let id = actors && actors.length > 0 ? actors[actors.length - 1].id : '',
body = requestsync('GET', url + '/api/statuses/networkpublic_timeline?max_id=' + id + '&only_media=false&count=20&with_muted=true')
try {
actors = JSON.parse(body.getBody())
if (actors && actors.length > 0) {
for (let a of actors) {
if (a && a.user && a.user.id && !followed.some(f => f === a.user.id)) {
requestsync('POST', url + '/api/v1/accounts/' + a.user.id + '/follow')
if (a.in_reply_to_user_id && !followed.some(f => f === a.in_reply_to_user_id)) {
requestsync('POST', url + '/api/v1/accounts/' + a.in_reply_to_user_id + '/follow')
followed.push(a.in_reply_to_user_id)
console.log('followed: ' + a.in_reply_to_user_id)
}
followed.push(a.user.id)
console.log('followed: ' + a.user.screen_name)
}
}
}
} catch (e) {
console.log(e)
}
console.log(url)
} while (actors && actors.length >= 20)
} catch (e) {
console.log(e)
}