Updated fanbase, claiming rewards and upvoting comments on Steemauto

in #utopian-io6 years ago (edited)

steemauto.png

Updated some codes on back-end of steemauto.com
By these changes, fanbase and upvoting comments should work fine.
You don't need to understand that codes.

Commits:
Number 1: Streaming blocks and detecting posts which are authored by fans. Then upvoting that posts.
Some codes:

...
...
// Upvoting Fanbase Followers
var fanupvote = function(author,permlink){
    try{
        var datee = new Date();
        var secondss = datee.getTime()/1000;
        con.query('SELECT `follower`,`weight`,`aftermin` FROM `fanbase` WHERE `fan` = "'+author+'" AND `enable`="1"', function (error, results, fields) {
            for(i in results){
                var follower = results[i].follower;
                var voted = 0;
                if(voted == 0){
                    var weight = results[i].weight;
                    var aftermin = results[i].aftermin;
                    var datee = new Date();
                    var secondss = datee.getTime()/1000;
                    var now = Math.floor(secondss);
                    if(aftermin > 0){
                        var time = parseInt(now+(aftermin*60));
                        con.query('INSERT INTO `upvotelater`(`voter`, `author`, `permlink`, `weight`, `time`,`trail_fan`) VALUES ("'+follower+'","'+author+'","'+permlink+'","'+weight+'","'+time+'","2")', function (error, results, fields) {
                        });
                        console.log('fan to delay');
                    }else{
                        upvote(follower,author,permlink,weight);
                        console.log('fan to up');
                    }
                }
            }   
        });
    }
    catch(e){
        console.log('error in fan upvote.'+e);
    }
}
...
...

Number 2: Checking users every 15 minutes and checking their reward balance. then claiming that rewards.
Some codes:

...
...
//broadcasting claim reward with adding to queue
//queue will prevent blockchain spamming
var delay3 = 0;
function broadcastclaim(username,sbd,vest){
    delay3 = delay3 +1;
    setTimeout(function(){
        steem.broadcast.claimRewardBalance(wifkey,username,'0.000 STEEM',sbd,vest, function(err, result) {
            if(err){
                console.log('err in claim2.');
            }else{
                console.log('claim done.');
            }   
        });
        delay3 = delay3 -1;
    },100*delay3);
    return 1;
}
...
...

Number 3: Streaming blocks and detecting comments on configured users. Then upvoting configured commenters.
Some codes:

...
...
// Upvoting Comments Automatically //
var delay2 = 0;
function commentupvote(userr,commenter,permlink,parentpermlink){ 
    try{
        con.query('SELECT EXISTS(SELECT * FROM `commentupvote` WHERE `user` = "'+userr+'" AND `commenter`="'+commenter+'" AND `enable`="1" AND `todayvote`<2)', function (error, results, fields) {
            for(i in results){
                for(j in results[i]){
                    if(results[i][j] == 1){
                        con.query('SELECT EXISTS(SELECT * FROM `upvotedcomments` WHERE `user` = "'+commenter+'" AND `permlink`="'+parentpermlink+'")', function (error, results, fields) {
                            for(o in results){
                                for(p in results[o]){
                                    if(results[o][p] == 0){
                                        con.query('SELECT `weight`,`aftermin` FROM `commentupvote` WHERE `user` = "'+userr+'" AND `commenter`="'+commenter+'" AND `enable`="1" AND `todayvote`<2', async function (error, results, fields) {
                                            for(k in results){
                                                var weight = results[k].weight;
                                                var aftermin = results[k].aftermin;
                                                var datee = new Date();
                                                var secondss = datee.getTime()/1000;
                                                var now = Math.floor(secondss);
                                                if(aftermin > 0){
                                                    var time = parseInt(now+(aftermin*60));
                                                    con.query('INSERT INTO `upvotelater`(`voter`, `author`, `permlink`, `weight`, `time`,`trail_fan`) VALUES ("'+userr+'","'+commenter+'","'+permlink+'","'+weight+'","'+time+'","3")', function (error, results, fields) {
                                                    });
                                                    con.query('UPDATE `commentupvote` SET `todayvote`=`todayvote`+1 WHERE `user` = "'+userr+'" AND `commenter`="'+commenter+'"', function (error, results, fields) {
                                                    });
                                                    con.query('INSERT INTO `upvotedcomments`(`user`, `permlink`,`time`) VALUES ("'+commenter+'","'+parentpermlink+'","'+now+'")', function (error, results, fields) {
                                                    });
                                                    console.log('comment to delay');
                                                }else{
                                                    console.log('comment to upvote');
                                                    upvote(userr,commenter,permlink,weight);
                                                    con.query('INSERT INTO `upvotedcomments`(`user`, `permlink`,`time`) VALUES ("'+commenter+'","'+parentpermlink+'","'+now+'")', function (error, results, fields) {
                                                    });
                                                    con.query('UPDATE `commentupvote` SET `todayvote`=`todayvote`+1 WHERE `user` = "'+userr+'" AND `commenter`="'+commenter+'"', function (error, results, fields) {
                                                    });
                                                }
                                            }
                                        });
                                    }
                                }
                            }
                        });
                    }
                }
            }
        });
    }
    catch(e){
        console.log('error in comment upvote.');
    }
}
...
...

More information about codes included as comments on each file.


What is Steemauto?

Steemauto comes with amazing features, Schedule post, Build a Fanbase, or leave a curation trail for users all around the world to follow.
Steemauto is open source, unlimited, secure and free app for steem users.


Regards,
Steem witness,
Mahdi Yari,
2018-01-30



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Excelent job! We need all this.

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Nice work!

Wow, i love this info. Thanks @mahdiyari. Keep us updated

this a good news for us also thanks for informing about this.

Awesome my brother @mahdiyari always tells us a lot. We learn from you always do not skimp on us information. I follow all that is new about you. Thank you

Congratulation my friend

can new user use it?

yes. maybe some features.

Wow you are doing great, so many recent updates - thank you for sharing and keep improving the steemit community with your development!

Thank you sir for contributing a valuable information
It is most important for me

Coin Marketplace

STEEM 0.27
TRX 0.13
JST 0.032
BTC 62622.67
ETH 2944.91
USDT 1.00
SBD 3.61