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

in hive-180932 •  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社区用户更有机会获得某大佬的点赞

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

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!

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

  ·  4 years ago 

你好鸭,村长!

@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.

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

  ·  4 years ago 

村长管理咱社区有道👏

  ·  4 years ago 

test

  ·  4 years ago 

test

  ·  4 years ago 

test