My little voting robot.

2 years ago

Hi guys, after several days without posting here I leave a little voting robot that I did a few months ago.

The robot will help you vote the last publication of each of the users you choose through your friends list, you can also level how much you want to vote and also avoid double upvoting. Each of these functions are specified in each of the lines of the code below.

'use strict'

const colors = require('colors');                                                               // Don't Edit this part
const wkd = require('steem');                                                                   // Don't Edit this part
wkd.api.setOptions({ url: 'wss://standbi.weku.io:8190' });                                      // Don't Edit this part
wkd.config.set('address_prefix', 'WKA');                                                        // Don't Edit this part
wkd.config.set('chain_id','b24e09256ee14bab6d58bfa3a4e47b0474a73iz5c6c47eeea007848195fa085e');  // Don't Edit this part

var voter = "hadrien.rivere";                                                                   // Your Account Name
var wif = "5K2...";                                                                             // Your active key
var wifPosting = '5J5...';                                                                      // Your posting key
var weight = 500;                                                                               // Weight of the vote 1000 = 10%, 10000 = 100%                  

var title = '';                                                                                 // Don't Edit this part
var jsonMetadata =  { tags: ['wekunow', 'bot', 'upvote'], app: 'wekunow/Bot' };           // Tags,  don't edit app object

var u = 0;                                                                                      // Don't Edit this part
const friends = [
      'martinphoto',
      'eddy',
      'monpora',
      'khairulmuammar',
      'munis'
];                                                                                              // Your Friend list.

var commentBody = [
  'You have received a Upvote via PAPU bot with: ' + weight/100 +  ' % weight.',
  'You have received a Upvote via Hadrien.Rivere bot with: ' + weight/100 +  ' % weight.',
  'You have received a Upvote via Wekubuster bot with: ' + weight/100 +  ' % weight.'
];                                                                                              // Change the comments here and add the ones you want.

var myInt = setInterval(function () {

  if (u < friends.length) {

    wkd.api.getDiscussionsByBlog({tag: friends[u++], limit: 1}, (err, res) => { 
        var author = res[0].author;
        var permlink = res[0].permlink;
      
    wkd.api.getActiveVotes(author, permlink, (err, res) => {

    var verifyVote = false;
    var body = commentBody[Math.floor(Math.random()*commentBody.length)];
    var comment_permlink = new Date().toISOString().replace(/[^a-zA-Z0-9]+/g, '').toLowerCase();      // Don't Edit this part

    for (var i = 0; i < res.length; i++) {
        var post = res[i].voter;
        if (res[i].voter == voter) {
            verifyVote = true;
        }
    }

    if (verifyVote) {
      console.log("[Weku Bot] says:".yellow, "The Post:", permlink, "of the user", author, "has already been voted.");
    }else{
      wkd.broadcast.vote(wif, voter, author, permlink, weight, (err, res) => { 
            console.log("[Weku Bot] says: ".yellow + "Your Friend " + author + " Got " + weight/100 + "% Upvote For his last post.");
      });
      wkd.broadcast.comment(wifPosting, author, permlink, voter, comment_permlink, title, body, jsonMetadata, (err, res) => {
            console.log("[Weku Bot] says: ".yellow + "We have announced to your friend " + author + " that you have voted his last post a weight: " + weight/100 + " %.");
      });
    }
    });
  });
}
}, 30000);

console.log('[Author] Says:'.yellow, 'The robot is ready to be used.');

How to execute:

Create a folder on your desktop with the name you want.

Go to the folder that you recently created through the console.

example:
cd / home / hadrien / bot

Once in the "boot" folder, install the following dependencies through npm.

npm i colors
npm i steem

Create a file called bot.js and copy the code above mentioned, complete the fields that are mentioned in each of the lines of the code. Once you have completed the fields, save the file, go to the console and execute the following command.

node bot.js

Now he has a bot that will free him from a little work.

without more to say I invite you to visit my little explorer of the block chain of weku.io: http://wekunow.com also do not forget to vote for me at: https://news.weku.io/~witnesses

thanks you!!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE WEKU!
Sort Order:  trending

You are really incredible, we need people like you to create an application like wekuauto or wekuvoter for users like me that doesn't understand what you are saying.

·

although I have the domain wekuauto.com I do not think I really carry out that project.

I would like to set this up for my account, but I have no idea what you are explaining, haha you have my vote

·

Learning a little about JS will help you to understand better.

great work

Gran aporte amigo @hadrien.rivere!! Te felicito!

Congratulations on the initiative and your work.

·

thanks you!!

Excellent!

This is a FAN Vote BOT

There are 2 parts we don't like is the spam comment it leaves behind the vote.

It is not an opts out comment and most users will just run the code and that will make proliferate the BOT spam, we have realized there are a bunch of projects already using something similar and we worry about it.

We are rewarding this contribution, however we will appreciate if you could edit the code and remove the comment part, we do NOT want to encourage any form of BOT spam in the platform.

For your next bots we suggest you take a look at account_history API it is much more efficient to gather account activity and it is easier on the RPC nodes.

Also you obtain all account activity, it also provides a transaction index number you can memorize so the next request you do to the nodes you take on the last operation checked for each account.

The other part is that your bot will pound with requests the RPC nodes every 30 seconds, if enough people runs this bot at the same time it will slow down the platform for the human users.

Put a bigger interval 15 to 30 minutes should be enough and even better, 1 or 2 times a day.

BOT development should be a responsible task weighting the impact both on the resources and on the interactions.

·

if the other projects use a more advanced version of this bot. If I already knew about getAccountHistory this is a very basic bot. Later maybe I develop an interface taking into account your comments.

·
·

The problem with doing the edition of the free code, later is that people will find this post, follow your instructions, copy paste and use it.

They will be creating several heavy requests every 30 seconds to the RPC nodes and the whole platform will slow down.

This will translate in an unwillingly distributed DDOS attack.

We want to encourage the development of the platform and we need to take this into consideration when we release code that is susceptible of being used by many users with limited knowledge of the overall impact.

·
·
·

If you feel that with your upvote this code will reach more people, feel free to remove it.

·
·
·
·

We want to encourage more people developing and making nice things that help everyone, whileit is true that you are not responsible for what people does with the code, the responsible thing is propose code that will minimize the the impact, the blockchain belongs to all, you are a witness, itis our role to discuss and advice in how to better protect.

We are only suggesting you increase the interval of your bot and suggestion you make the comment an option to be turned on/off and that is by default off.

You bot helps communities or users, we don't see what the problem is.

Our team cannot do magic to prevent people from using the bot as is, and the results will be nefarious for the chain if it gets popular.

We are already telling you of the potential problems the code would create and suggesting a solution for it.

That is the best our team can do to increase the security.

It is not a matter of removing the vote or not, you are making a contribution and it deserves to be rewarded, but also you can accept a suggestion that will make everything better for all in the platform.

·
·
·
·
·

before continuing, have you tried this code?

·
·
·

I am not responsible for what people do or do not do with the code.

·
·
·

Doing this type of codes encourages the increase of security. Nathan is here, he should be able to deal with this.

بہت اچھا کام کیا ہے۔ تم نے شکریہ

Thats great, I will also try. If I have any problem then I will ask you for guidance. Please update if any other such tools are invented.

  • Node is standby.weku.io, not standbi

  • colors library is never used but defined at the beginning of the code

  • It would be cool if you could add custom comments for each friend. I made a small version inspired by yours. :) It doesn't add comments but it has custom settings for each friend.

·
  • It's the standby thing that damages it on purpose.
  • colors if used
  • Thanks for your edit.
·
·

Does "colors" act without you calling it? Oof, my bad. I hadn't thought it would be one of those magical thingies you find in the wild sometimes.

·
·
·

check the console.log there you will see

The more repetitive tasks you can automate the better, thanks for the information and help!