1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| 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'); }
}); }
|