Skip to content

Commit

Permalink
filter users demonstration
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamCox9 committed Feb 16, 2018
1 parent fa7bf28 commit 1b16037
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 6 deletions.
9 changes: 5 additions & 4 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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 = 100;
config.steem.delay = 200;

//must be from username, goes with demo start.js
config.steem.sample_post = 'creating-first-steemit-bot';
Expand All @@ -21,11 +21,12 @@ config.steem.start = "";

//memos only
config.steem.type = 'followers'; //either following or followers
config.steem.message = 'Hi @username!'; //message to be sent in each memo (@username will be replaced)
config.steem.message = 'Hi @username Your earnings: 0.001 SBD https://steemit.com/follow/@money-dreamer/follower-earnings Un/follow to un/subscribe.'; //message to be sent in each memo (@username will be replaced)
config.steem.amount = '0.001 SBD'; //amount of SBD or STEEM to send to each follower/following
config.steem.send_memos_to = null;

//curation only
config.steem.type = 'created'; //created, hot or trending
config.steem.curation_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

Expand All @@ -41,7 +42,7 @@ config.steem.require_resteem = true;//a comment entry must contain an image to q
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.follow_accounts_from = 'jerrybanfield';//ned, dan
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

Expand Down
2 changes: 2 additions & 0 deletions library.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var mTimeout = 0;
module.exports = {
getFollowing: function(username=config.steem.username,start=config.steem.start,count=100,callback) {
steem.api.getFollowing(username, start, 'blog', 100, function(err, result){
console.log( err, result );
start = '';
count = result.length;
for (let i = 1; i < count; i++) {
Expand All @@ -22,6 +23,7 @@ module.exports = {
},
getFollowers: function(username=config.steem.username,start=config.steem.start,count=1000,callback) {
steem.api.getFollowers(username, start, 'blog', 100, function(err, result){
console.log( err, result );
start = '';
count = result.length;
for (let i = 0; i < count-1; i) {
Expand Down
74 changes: 72 additions & 2 deletions send_memo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,84 @@ var config = require('./config');
var library = require('./library');
var library_auth = require('./library_auth');

var steem = require('steem');
steem.api.setOptions({ url: config.steem.url });

function filterAccounts( accounts = [] ) {

steem.api.getAccounts(accounts, function(err, response){
let filtered_accounts = [];
for (var i = response.length - 1; i >= 0; i--) {
if( parseInt(response[i].reputation) > parseInt(1000000) ) {
if (
response[i].name.charAt(0) !== 'C' &&
response[i].name.charAt(0) !== 'c' &&
response[i].name.charAt(0) !== 'D' &&
response[i].name.charAt(0) !== 'd' &&
response[i].name.charAt(0) !== 'E' &&
response[i].name.charAt(0) !== 'e' &&
response[i].name.charAt(0) !== 'F' &&
response[i].name.charAt(0) !== 'f' &&
response[i].name.charAt(0) !== 'G' &&
response[i].name.charAt(0) !== 'g' &&
response[i].name.charAt(0) !== 'H' &&
response[i].name.charAt(0) !== 'h' &&
response[i].name.charAt(0) !== 'I' &&
response[i].name.charAt(0) !== 'i' &&
response[i].name.charAt(0) !== 'J' &&
response[i].name.charAt(0) !== 'j' &&
response[i].name.charAt(0) !== 'K' &&
response[i].name.charAt(0) !== 'k' &&
response[i].name.charAt(0) !== 'L' &&
response[i].name.charAt(0) !== 'l' &&
response[i].name.charAt(0) !== 'M' &&
response[i].name.charAt(0) !== 'm' &&
response[i].name.charAt(0) !== 'N' &&
response[i].name.charAt(0) !== 'n' &&
response[i].name.charAt(0) !== 'O' &&
response[i].name.charAt(0) !== 'o' &&
response[i].name.charAt(0) !== 'P' &&
response[i].name.charAt(0) !== 'p' &&
response[i].name.charAt(0) !== 'Q' &&
response[i].name.charAt(0) !== 'q' &&
response[i].name.charAt(0) !== 'R' &&
response[i].name.charAt(0) !== 'r' &&
response[i].name.charAt(0) !== 'S' &&
response[i].name.charAt(0) !== 's' &&
response[i].name.charAt(0) !== 'T' &&
response[i].name.charAt(0) !== 't' &&
response[i].name.charAt(0) !== 'U' &&
response[i].name.charAt(0) !== 'u' &&
response[i].name.charAt(0) !== 'V' &&
response[i].name.charAt(0) !== 'v' &&
response[i].name.charAt(0) !== 'W' &&
response[i].name.charAt(0) !== 'w' &&
response[i].name.charAt(0) !== 'X' &&
response[i].name.charAt(0) !== 'x' &&
response[i].name.charAt(0) !== 'Y' &&
response[i].name.charAt(0) !== 'y' &&
response[i].name.charAt(0) !== 'Z' &&
response[i].name.charAt(0) !== 'z'
) {
filtered_accounts.push( response[i].name );
}
}
}

let count = accounts.length - filtered_accounts.length;
console.log( 'filtered accounts: ' + count );
library_auth.sendMemos( filtered_accounts );
});
}

if( config.steem.send_memos_to !== null ) {
library_auth.sendMemos( config.steem.send_memos_to )
return;
}

if( config.steem.type === 'followers')
library.getFollowers(config.steem.username,config.steem.start,1000,library_auth.sendMemos);
library.getFollowers(config.steem.username,config.steem.start,1000,filterAccounts);
else if( config.steem.type === 'following')
library.getFollowing(config.steem.username,config.steem.start,100,library_auth.sendMemos);
library.getFollowing(config.steem.username,config.steem.start,100,filterAccounts);
else
console.log( 'config.steem.type needs to be followers or following')

0 comments on commit 1b16037

Please sign in to comment.