Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Upvote-Bot's in Steem-js</title>
  4. <script src="https://cdn.steemjs.com/lib/latest/steem.min.js"></script>
  5. <script>
  6. console.log('Hello, Is Anybody OUt There!?')
  7. // Tutorial 04 - Paid Upvote Bot
  8. const ACCOUNT_NAME = 'TON @ ICI ET JUSTE ICI PAS AILLEURS PLEASE MERCI BEAUCOUP ! MDRRR'
  9. const ACCOUNT_KEY = 'ET ICI TU MET TON NUMERO DE CB LA DATE D EXPIRATION ET LE CRYPTOGRAMME. SI T AS PAS DE CB SUR TOI MET JUSTE TA POSTING KEY PUIS C EST TOUT'
  10. steem.api.setOptions({ url: 'https://api.steemit.com/' });
  11. steem.api.streamTransactions('head', function(err, result) {
  12. let txType = result.operations[0][0]
  13. let txData = result.operations[0][1]
  14. if(txType == 'transfer' && txData.to == ACCOUNT_NAME) {
  15. sendVote(txData.from, txData.memo, txData.amount)
  16. }
  17. });
  18. function sendVote(author, memo, amountPaid){
  19. let memoToPermlink = memo.split('/')
  20. let permlink = memoToPermlink.pop()
  21. let weight = calcVoteWeight(amountPaid)
  22. console.log ( author, permlink, weight )
  23. steem.broadcast.vote(ACCOUNT_KEY, ACCOUNT_NAME, author, permlink, weight, function(err, result) {
  24. console.log(err, result)
  25. console.log(`WE have just voted on the post by ${author} with a vote power of ${weight/100}%`)
  26. });
  27. }
  28. function calcVoteWeight(amountPaid) {
  29. let token = amountPaid.split(' ')
  30. let tokenType = token.pop()
  31. let tokenValue = token.shift()
  32. let weight;
  33. let steemToSbdRatio = 0.8
  34. if (tokenValue >= 1){
  35. weight = 100
  36. } else if (tokenValue >= 0.5) {
  37. weight = 50
  38. } else {
  39. weight = 10
  40. }
  41. if( tokenType == 'STEEM') {
  42. return (weight * steemToSbdRatio) * 100
  43. } else {
  44. return weight * 100
  45. }
  46. }
  47. </script>
  48. </head>
  49. <body></body>
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement