Last active
November 29, 2018 15:08
-
-
Save jonmaim/55a1bef508af32f3d4e6cb9794bdbb7c to your computer and use it in GitHub Desktop.
First steem voting bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const steem = require('steem'); | |
/* to be filled up */ | |
const selfName = ''; | |
const postingWif = ''; | |
const eol = '\n'; | |
steem.api.getFollowing(selfName, 0, 'blog', 100, (err, result) => { | |
if (err) { throw err; } | |
const followerUsernames = result.map(r => r.following); | |
console.log('Followers:', eol); | |
console.log(followerUsernames); | |
const rndIdx = Math.floor(Math.random() * followerUsernames.length); | |
const u = followerUsernames[rndIdx]; | |
console.log(eol, 'Chosen follower is:', eol); | |
console.log(u); | |
steem.api.getDiscussionsByBlog({tag: u, limit: 1}, (err, posts) => { | |
if (err) { throw err; } | |
console.log(eol, 'Post fields:', eol); | |
console.log(Object.keys(posts[0])); | |
steem.broadcast.vote(postingWif, selfName, u, posts[0].permlink, 1000, (err, result) => { | |
if (err) { throw err; } | |
console.log(eol, 'Vote broadcast:', eol); | |
console.log(result); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment