RE: RE: Busy.org Boost Bot Test #2
You are viewing a single comment's thread from:

RE: Busy.org Boost Bot Test #2

Words
182
Reading
1 min
Listen
Play
8y

What framework do you use for that? I tried the console and it doesn't work :D I would have to use Dsteem or Steem-js on Nodejs. I rewrote it and want to try it out to see if it works but I don't know where to run the code for "steem" to be defined.

Lol, I can't make the code look pretty in a comment. Here's a pretty gist

const getFollowerCount = accName =>
  new Promise((resolve, reject) =>
    steem.api.getFollowCount(accName, (e, r) =>
      e ? reject(e) : resolve(r.follower_count)))
const getFollowers = accName =>
  getFollowerCount(accName).then(count =>
    new Promise((resolve, reject) =>
      steem.api.getFollowers(accName, 0, 'blog', count, (e, r) =>
        e ? reject(e) : resolve(r.map(f => f['follower'])))))
const getSteemPowerValue = () =>
  new Promise((resolve, reject) =>
    steem.api.getDynamicGlobalProperties((e, r) =>
      r.total_vesting_fund_steem.replace(" STEEM", "")
        / r.total_vesting_shares.replace(" VESTS", "")))
const calcSP = (userTotalVest, steemPower) =>
  userTotalVest * steemPower
const getAccountTotalVest = accData =>
  parseInt(accData.vesting_shares.replace(" VESTS", ""))
    - parseInt(accData.delegated_vesting_shares.replace(" VESTS", ""))
    + parseInt(accData.received_vesting_shares.replace(" VESTS", ""))
const getTotalFollowerSP = accName =>
  getFollowers(accName).then(followers =>
    new Promise((resolve, reject) =>
      steem.api.getAccounts(followers, (e, r) =>
        e ? reject(e) : resolve(r.reduce((sum, accData) =>
          sum + getAccountTotalVest(accData))))))
getTotalFollowerSP('cryptosharon').then(console.log)
@cryptosharon: What framework | Ecency