Skip to content

Commit

Permalink
follow_accounts, add username to library function
Browse files Browse the repository at this point in the history
create follow_accounts bot; update library & files that use getFollowing/ers function; make more configurable
  • Loading branch information
AdamCox9 committed Feb 12, 2018
1 parent ae6c151 commit fa7bf28
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 28 deletions.
19 changes: 16 additions & 3 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ config.steem.url = 'wss://steemd-int.steemit.com';
config.steem.auth_type = 'owner'; //owner, posting

//delay in milliseconds between each write transaction
config.steem.delay = 1000;
config.steem.delay = 100;

//must be from username, goes with demo start.js
config.steem.sample_post = 'creating-first-steemit-bot';

//optional account to start at in alphanumerisymbolical order
//this is not applicable in follow_trending_authors, follow_back, generate_contest_winners bots
//todo - add this config to other applicable bots; create a config.steeem.end that works much the same
config.steem.start = "";

//memos only
Expand All @@ -28,15 +29,27 @@ config.steem.type = 'created'; //created, hot or trending
config.steem.tags = ['steem','steemit','utopian-io']; //tags. leave empty for all trending tags
config.steem.vote_percent = 1; //percentage of vote for each vote


//generate_contest_winners only

config.steem.contest_permlink = '30-sbd-webgl-screen-capture-contest';//link to post where contest is being held - must be by config.steem.username set above
config.steem.contest_sublink = 'https://experiments.withgoogle.com/chrome/';//a comment entry must contain a URL with this sublink (only if require_link true)
config.steem.require_graphic = true;//a comment entry must contain an image to qualify
config.steem.require_link = true;//a comment entry must contain link with sublink to qualify
config.steem.require_followers = true;//contestents must be following to qualify
config.steem.require_resteem = true;//a comment entry must contain an image to qualify

//follow_back only
config.steem.unfollow_nonfollowers = false; //if a user unfollows this account, then unfollow them

//follow_accounts only
config.steem.follow_accounts_from = 'jerrybanfield';
config.steem.accounts_to_follow = []; //this will be ignored if config.steem.follow_accounts_from is not null
config.steem.follow_accounts_type = 'following'; //either following or followers

//get_reblogs_steemsql only
config.steem.steemsql_username = 'Steemit-money-dreamer';
config.steem.steemsql_password = 'Gmt3tkmY5FBw64Htw9GH';
config.steem.steemsql_server = 'vip.steemsql.com';
config.steem.steemsql_database = 'DBSteem';

//and thats that
module.exports = config;
4 changes: 2 additions & 2 deletions deep_follow.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function followAccount(following) {
}

//These are the accounts of the users that you are following follow
async function getNewFollowing(account='',start='',count=100) {
async function getNewFollowing(account=config.steem.username,start=config.steem.start,count=100) {
steem.api.getFollowing(account, start, 'blog', 100, function(err, result){

start = '';
Expand Down Expand Up @@ -70,4 +70,4 @@ async function startFollowingAccounts(following=[]) {
}

//Start the chain:
library.getFollowing(config.steem.start,100,startFollowingAccounts);
library.getFollowing(config.steem.username,config.steem.start,100,startFollowingAccounts);
12 changes: 12 additions & 0 deletions follow_accounts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var config = require('./config');
var library = require('./library');
var library_auth = require('./library_auth');

function startFollowingAccounts(accounts=[]) {
library_auth.followAccounts(accounts,["blog"]);
}

if( config.steem.follow_accounts_from !== null )
library.getFollowing(config.steem.follow_accounts_from,config.steem.start,100,startFollowingAccounts);
else
startFollowingAccounts( config.steem.accounts_to_follow );
12 changes: 7 additions & 5 deletions follow_back.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ function finishGetFollowers(followers=[]) {
followersArray = followers;

//Unfollow accounts that are no longer followers but were before:
var toUnfollow = _.difference( followingArray, followersArray );
console.log( 'old followers not following anymore: '+toUnfollow.length );
//library_auth.followAccounts( toUnfollow, [""] );
if( config.steem.unfollow_nonfollowers ) {
var toUnfollow = _.difference( followingArray, followersArray );
console.log( 'old followers not following anymore: '+toUnfollow.length );
//library_auth.followAccounts( toUnfollow, [""] );
}

//Follow accounts that are now followers but weren't before:
var toFollow = _.difference( followersArray, followingArray );
Expand All @@ -23,8 +25,8 @@ function finishGetFollowers(followers=[]) {
}
function finishGetFollowing(following=[]) {
followingArray = following;
library.getFollowers(config.steem.start,1000,finishGetFollowers)
library.getFollowers(config.steem.username,config.steem.start,1000,finishGetFollowers)
}

//Start the chain:
library.getFollowing(config.steem.start,100,finishGetFollowing);
library.getFollowing(config.steem.username,config.steem.start,100,finishGetFollowing);
2 changes: 1 addition & 1 deletion follow_trending_authors.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async function followAccountsInTrending(result) {

}

//So we don't try to follow someone we are already following:
//TODO move this to library.js
function getFollowing(start=config.steem.user,count=100) {
//console.log( 'test' );
steem.api.getFollowing(config.steem.username, start, 'blog', 100, function(err, result){
Expand Down
2 changes: 1 addition & 1 deletion generate_contest_winners.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,4 @@ function finishGetFollowers(followers=[]) {
}

//Get followers
library.getFollowers('',1000, finishGetFollowers);
library.getFollowers(config.steem.username,'',1000, finishGetFollowers);
9 changes: 4 additions & 5 deletions get_reblogs_steemsql.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
const sql = require('mssql');
const util = require('util')


const config = {
user: 'Steemit-money-dreamer',
password: 'Gmt3tkmY5FBw64Htw9GH',
server: 'vip.steemsql.com',
database: 'DBSteem',
user: config.steem.steemsql_username,
password: config.steem.steemsql_password,
server: config.steem.steemsql_server,
database: config.steem.steemsql_database,
}

sql.connect(config).then(pool => {
Expand Down
12 changes: 6 additions & 6 deletions library.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ var followersArray = [];
var mTimeout = 0;

module.exports = {
getFollowing: function(start=config.steem.start,count=100,callback) {
steem.api.getFollowing(config.steem.username, start, 'blog', 100, function(err, result){
getFollowing: function(username=config.steem.username,start=config.steem.start,count=100,callback) {
steem.api.getFollowing(username, start, 'blog', 100, function(err, result){
start = '';
count = result.length;
for (let i = 1; i < count; i++) {
followingArray.push(result[i].following);
start = result[i].following;
}
if( count === 100 )
module.exports.getFollowing( start, count, callback );
module.exports.getFollowing( username, start, count, callback );
else
callback(followingArray);
});
},
getFollowers: function(start='',count=1000,callback) {
steem.api.getFollowers(config.steem.username, start, 'blog', 100, function(err, result){
getFollowers: function(username=config.steem.username,start=config.steem.start,count=1000,callback) {
steem.api.getFollowers(username, start, 'blog', 100, function(err, result){
start = '';
count = result.length;
for (let i = 0; i < count-1; i) {
followersArray.push(result[++i].follower);
start = result[i].follower;
}
if( count === 100 )
module.exports.getFollowers( start, count, callback );
module.exports.getFollowers( username, start, count, callback );
else
callback(followersArray);
});
Expand Down
4 changes: 2 additions & 2 deletions publish_post.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* @params username, password, parentAuthor, parentPermlink, author, permlink, title, body, jsonMetadata */
steem.broadcast.comment('fabien', 'sgs56sd84hbr51qpodg1',
/*steem.broadcast.comment('fabien', 'sgs56sd84hbr51qpodg1',
'',
'steemjs',
'fabien',
Expand All @@ -9,4 +9,4 @@ steem.broadcast.comment('fabien', 'sgs56sd84hbr51qpodg1',
{tags: ['steemjs', 'steem']},
function(err, result) {
console.log(err, result);
});
});*/
4 changes: 2 additions & 2 deletions send_memo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ if( config.steem.send_memos_to !== null ) {
}

if( config.steem.type === 'followers')
library.getFollowers(config.steem.start,1000,library_auth.sendMemos);
library.getFollowers(config.steem.username,config.steem.start,1000,library_auth.sendMemos);
else if( config.steem.type === 'following')
library.getFollowing(config.steem.start,100,library_auth.sendMemos);
library.getFollowing(config.steem.username,config.steem.start,100,library_auth.sendMemos);
else
console.log( 'config.steem.type needs to be followers or following')
2 changes: 1 addition & 1 deletion unfollow.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ function startUnfollowingAccounts(accounts=[]) {
library_auth.followAccounts(accounts,[""]);//empty to unfollow
}

library.getFollowing(config.steem.start,100,startUnfollowingAccounts);
library.getFollowing(config.steem.username,config.steem.start,100,startUnfollowingAccounts);

2 comments on commit fa7bf28

@cemke
Copy link

@cemke cemke commented on fa7bf28 May 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello sir, I want to unfollow all of my following list. How can I do it?

@AdamCox9
Copy link
Owner Author

@AdamCox9 AdamCox9 commented on fa7bf28 May 23, 2018 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.