Updated fanbase, claiming rewards and upvoting comments on Steemauto

in #utopian-io7 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.

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

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

Well done... I've signed up in steemauto few weeks ago, but actually starting using it since yesterday for the first time. I used the manual curation service which was very smooth and easy to you. But I wanted to ask you about the auto follow / follower service, is it off now?

thanks for informations

Fantastic information. Thanks :)

Thank you for the update @mahdiyari

"You don't need to understand that codes." this information so important for me. Because i dont understand codes :)

Hey @mahdiyari I am @utopian-io. I have just upvoted you!

Achievements

  • WOW WOW WOW People loved what you did here. GREAT JOB!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

thanks info @mahdiyari

Thank you for updating about something new always, keep posting!

"You don't need to understand that codes."

Yeah I don't need to coz I know its great update :)

It's really good the way you are giving a good message to the world,,,,
I love your post,,, thank you my dear friend for sharing with #Us,,,,,,, and very good job,,,keep it #Up,,,

Thanks for the awesome post. I have followed, upvoted your post. Just follow me and upvote this comment for future upvote for your content.
Please 1 vote me..

Perfect

well done!

Wow saya baru mengetahui hal ini , terimakasih @mahdiyari saya akan mengikuti selalu perkembangan terbaru dari postingan anda