const steem = require('steem'); const account = 'STEEM ID'; const wif = 'POSTING KEY';
start()
function start() { steem.api.streamTransactions('head', async function (err, result) { let txType = result.operations[0][0] let txData = result.operations[0][1] if (txType === 'comment') { if (txData.parent_author === '' && txData.parent_permlink === 'hive-180932') { let rep = await getAccountReputation(txData.author); if (rep <= 25) { console.log(`${txData.author}:${rep}`) mutePost(txData.author, txData.permlink); muteUser(txData.user); } } } }); }
function getAccountReputation(user) { return new Promise((resolve) => { steem.api.getAccounts([user], (err, result) => { if (!err && result[0]) { resolve(steem.formatter.reputation(result[0].reputation)); } else { resolve(null); } }); });
}
function muteUser(user) { let json = JSON.stringify( ['setRole', { community: 'hive-180932', account: user, role: 'muted' } ]); steem.broadcast.customJson(wif, [], [account], 'community', json, (err, result) => { if (err) console.log(err); else { console.log('success'); }
}); }
function mutePost(user, permlink) { let json = JSON.stringify( ['mutePost', { community: 'hive-180932', account: user, permlink: permlink, notes: 'muted' } ]); steem.broadcast.customJson(wif, [], [account], 'community', json, (err, result) => { if (err) console.log(err); else { console.log('success'); }
}); }
|