Updated fanbase, claiming rewards and upvoting comments on Steemauto

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@mahdiyari·
0.000 HBD
Updated fanbase, claiming rewards and upvoting comments on Steemauto
<center>![steemauto.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1517330470/hsqo20sfc66wxvxuwfqo.png)
</center>
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](https://github.com/mahdiyari/steemauto/commit/afc701670e79a4f4dace09ed41947ebae861332e): 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](https://github.com/mahdiyari/steemauto/commit/015ec44dffb1cb9c5d95c2f301791f545c3b3c8b): 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](https://github.com/mahdiyari/steemauto/commit/a293233ec17969285a72a2679ad66e6a1eeae2b8): 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

<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@mahdiyari/updated-fanbase-claiming-rewards-and-upvoting-comments-on-steemauto">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,