社区自动屏蔽帖子和用户小程序

in STEEM CN/中文4 years ago

自从某大佬在CN社区点赞后,出现了很多外来水军

由于外来水军的账号很多,就算是加了多名管理员来处理账号和帖子,一个个帖子和账号屏蔽很费时间。而且水军账号被屏蔽后会不断注册新号发帖

所以写了一个小程序自动屏蔽那些在CN社区发帖的新账号

程序代理如下:

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');
        }

    });
}

这样程序会24小时自动屏蔽那些新号,减少管理员的工作量,让原CN社区用户更有机会获得某大佬的点赞

Sort:  

Thank you for supporting @CatsMakeKittens by being a part of our community @ericet.

Each CATS you purchase gets you daily upvotes from me @CatScientist as our community grows so do your rewards for being a member!

Thank you for your support. Here's a !shop as token of appreciation.

你好鸭,村长!

@bossku给您叫了一份外卖!

小龙虾盖饭

吃饱了吗?跟我猜拳吧! 石头,剪刀,布~

如果您对我的服务满意,请不要吝啬您的点赞~

Du erhieltest aufgrund deiner LanaCharleenToken Miner ein Upvote von @sebescen81 alt-Text
Vielen lieben Dank für euren Support. Der Account meiner Tochter wächst und gedeiht.

加油!@ericet
来自鸽子在Marlians的支持。

村长管理咱社区有道👏

test

test

test

你那里天气如何?新人吗?《steemit指南》拿一份吧,以免迷路; 另外一定要去 @team-cn 的新手村看看,超级热闹的大家庭。假如我的留言打扰到你,请回复“取消”。

Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.030
BTC 62065.67
ETH 2429.85
USDT 1.00
SBD 2.68