Howto: Steemit Bot Tutorial For Newbies #1 - Votebot

in #howto8 years ago (edited)

This guide is meant to teach you, how to employ your own bot-agents for Steemit.
It's not the first guide of this kind ...
I will try to explain everything so that you need no prior experience at all.
All you need is a running version of Windows (maybe mac), an internet connection and some time.

In this first episode I will try to explain, how to employ a simple votebot, like in this guide by @xeroc

https://steemit.com/steem/@xeroc/upvote-bot-in-less-than-10-lines-of-code

I will not add anything to that script, but show how to actually run it on your computer at home.
I have written something similar on this blog before, but apparently failed to communicate, how really anybody can start developing with Python 3 and Piston.


Note:
Until some months ago, before I knew Steemit, I had been completely ignorant of Linux.
I was a Windows-user.
I also have very limited experience in programming.
This guide should work for most newbies.



For this guide I will use Ubuntu 16.04.1 in a virtual machine.
You will not need any prior experience with Linux, though.

Note: This is not the only way to do it and it might not be the easiest.
Because you can use Linux for other stuff too, I think it's a good way of introduction.

Step 1:

Environment

Download VMware Workstation and an Ubuntu 16.04.1 iso.
Install Ubuntu in a virtual machine.
This procedure is well documented all over the internet.
I just hope you can figure that out by searching the web.

If it all works right, you get to choose the virtual hardware for the machine.

I put it to:

  • 1 Processor
  • 2 Gig RAM
  • 20 G HD

That should be sufficient.

It should then look like this:

This way, you have a nice development environment.
If anything was to go wrong, you could just kill the virtual machine and start over again.

Step 2:

Piston

Documentation for Piston:
https://piston.readthedocs.io/en/stable/

Open a terminal with ctrl+alt+T.

Install Piston:
https://piston.readthedocs.io/en/stable/installation.html

It says this command will install piston:

pip3 install steem-piston

It will return an error:

The program 'pip3' is currently not installed [...]

This friendly message also tells us, how to fix it.
Type:

sudo apt install python3.pip

Confirm with your password.
Confirm with 'Y'.

Once that is done, retry

pip3 install steem-piston

It should work now - Yet, it doesn't.
Another friendly error message tells us what to do.

pip install --upgrade pip

This will cause another error message.
This one tells us to try this:

sudo apt install python-pip

Confirm with your password.
Confirm with 'Y'.

This still won't work.
This will fix it:

sudo apt-get install build-essential libssl-dev libffi-dev python-dev

retry

pip3 install steem-piston

This should work, finally

piston --help

This should show you some of Piston's functions.

Some steps above were somewhat pointless, but this is the route I took.
This way it's reproducable at least ( I hope ).

Step 3

Python

We don't want to use Piston 'by hand' though - We want to automate it, right ?

You will need to create a new script.

gedit votebot.py

Will open an editor and a new file called 'votebot.py'.
This is my modified version of @xeroc 's example.
(I don't know how the environmental variables work)

from steem.steem import Steem
import os
import json
steem = Steem(wif="5yourpostingkeyhere")
authors = "felixxx", "deutschbot"
for c in steem.stream_comments():
    if c["author"] in authors:
        print(c.upvote(weight=100, voter="votebot"))

Important:

You will need to put your posting key into this script.
I don't know how safe this method is.
I can therefore NOT recommend it.
Use entirely at your own risk


Replace 5yourpostingkeyhere with your posting key.
Replace votebot with the account the above posting key belongs to.

After

authors = 

replace the list of authors with your favourite authors. (Keep the format)

Save the file.

Step 4

Finished !

Run your script like this:

python3 votebot.py

This bot will crash after a while.
Also, it's very simple and will vote any of the authors' posts, even the comments.

In terms of value, I would not recommend this approach for voting.

This is meant for educational purpose, mainly.

In the next episode I will try to explain, how to modify the bot, to make it act a little smarter.
That will mostly be about Python.

Ultimately the goal is to educate the readers of these posts to come up with their own modifications.

I doubt it would hurt Steemit, if more people joined the bot-game.

Especially, if those bots did more than just voting anything from a list.

Please also keep in mind: For this to work 24/7, your computer will need to run 24/7.
I imagine this to be a very annoying solution for most users.

Please let me know, if this tutorial worked for you.
I hope, I didn't make any mistakes.

Sort:  

This guide is over a year old.
Here is the latest working update on it:

https://steemit.com/steem-python/@felixxx/how-to-really-install-steem-python-ubuntu-17-10

@felixxx once 17.10 is installed will the winfrey auto curation bot still work? I've been chasing this down for a few days now and I remember seeing somewhere that piston no longer works but I couldn't find the fate of the winfrey bot. Thanks for your contributions to the community.

It will need some tweaks, since some functions have changed from piston to steem-python.

Can you add this as part of your learn python series? Got my raspberry pi 3 ordered so I can start trying to tinker with things.

If you can install a Linux with Python 3.6 (or higher), my latest tutorial series should work for you.

Aye thanks man, this post was really useful. I'm working on a few bots now!

Change the following line:

steem = Steem(wif="5yourpostingkeyhere")

to

steem = Steem(wif=os.environ['WIF_POSTING'])

Then, before you run the script, in the terminal, set the following environment variable:

export WIF_POSTING='5KDWWnSQiPtVhzCquaBWhbWS8UNoAkeNuuCm8uJJE6EiSqt514p'

(or whatever your WIF is, the above example is a worthless random key)

then run the script as normal. It will pick up the posting key from your WIF_POSTING environment variable. Now you can save your code on GitHub or wherever else safely. :)

Actually, since the latest release of python-steem, the library also contains a wallet that can be managed through piston.
Just import your keys with

piston addkeys

and use

from steem import Steem

Since wif keys are stored encrypted, you will be asked to provide the password when voting. If you want to unlock the wallet from script, you can use the UNLOCK environmental variable:

UNLOCK="wallet-passphrase" python3 bot.py

Thanks !

For the next episode I wanted to use a config file instead. :)

Hello @felixxx,

It gives us pleasure to inform you that you have been chosen as a featured author by the @robinhoodwhale initiative.

Learn more about the Robinhood Whale here!

We hope to see you continuing to post some great stuff on Steemit!

Good luck!
~RHW~

Thanks for sharing , I too must step out of the comfort of the windows dungeon at some point and explore the script world. I just bought a raspberry Pi for this pourpose but haven't had a chance to set it up as yet.

It's possible to run those Python scripts from Windows, too.

I hope this guide shows how quick and simple it can be.
It's more fun, when more people join.

so what if you have more than one votebot... does this work assuming they all have the same posting key?

print(c.upvote(weight=100, voter="votebot"))
print(c.upvote(weight=100, voter="votebot2"))
print(c.upvote(weight=100, voter="votebot3"))

if you had like 8000 votebots running like this, would that likely be prohibitively unstable?

When instanciating Steem() you can pass an array of wif keys:

steem = Steem(keys=[wif1, wif2, wif3]

of you install the keys into the library-internal wallet using pison

piston addkey

then you don't need to deal with keys in the script at all but need to provide the masterpassword for the wallet either in the terminal-prompt, or in the environmental variable UNLOCK

It would be better to put a multi select function that triggers votes from multiple bots in one. Each instance will be pulling the same data, it makes more sense to only do this once.

Yes if all the bots have the same key they can vote like you show.

Thanks for posting this. I am looking forward to your next post. I have some questions but my guess is that the answers will be covered there :)

Great post felixxx, I am looking forward to read more about it in the following episodes.

Hi felixxx, Could you make an update this instruction please?
Piston is not available on https://readthedocs.org/ anymore.
Thanks Buddy

Hi, @felixxx, thank you for your kind explanation. I tried to make a upvoting bot using your script, but I had an error... when I ran the script, it said that the post is not exist. also it seems like that the script is searching for other author's post, not mine..would you tell me the reason if you have any clues about this error?

That's a piston bug.

Try installing steem-python instead, that's the new library.

The second problem, I don't understand.

@felixxx Thank you for your reply, so you mean that I have to install the 'steem-python' instead of 'steem-piston' by typing a 'pip3 install steem-python' right? sorry to bother you so often.

I really appreciate it.

How about leaving it a vote then ?

yeap I did:)

Terimakasih atas informasinya @felixxx saya sangat menghargai nya

Great how-to and neat to hear about you learning this stuff recently.

I've been learning so much since joining steemit too, so thanks for sharing!

great article, been trying to learn something like this!

I've always wanted my own pet bot! Haha. Do you offer services creating bots for those of us who freeze up at the mention of using terminal ?

If you have a good idea, let me know ;)

it is such a ridiculously good idea (in my mind lol) that I don't want to just put it out here lol. You're on discord chat? My name is the same over there. I'm going to bed now, but will be on it tomorrow evening :-)

No, I don't like Discord.

I'm on https://steemit.chat though.

Cool I 'll find you on there tomorrow :-) I just realized my last comment sounded pretty arrogant and didn't mean it too ! When we non tech people 'discover' new technology the ideas we think are great - they are probably super expensive or not possible haha.

I THINK the idea I have is probably doable just based on the posts I've seen of yours.

Anyway - 'see' you on there :-)

Hi, Im using Vagrant to set up a virutal machine and having a lot of trouble downloading the steemit-piston library. When we try to run it, it says: "no command 'pip3' found" Any ideas? thanks

Hey man, great post, sounds like you know your shit.
I could really use some help, I am a beginner and I need some help with getting started. I would really apreciate a 5 minute chat with you where i can ask some questions.
if you are willing to help me out, could you reply with a way to contact you? (email,chat,skype,discord) or whatever you prefer so i can contact you.

This is all Greek to me. Please help me create a upvote bot like @booster. Email me at brazendale@gmail.com. Thanks

get for windows ?

Awesome!!! really undervaluated this post!

Testing this now .

Thanks mate! I will try this out! If have more tips/bot share please!

Hi, I would like to know if you can point me to a guide on how to create/prepare a bot account, I want to make a greeter bot and then just keep it up and running. So I want to have a separate account to do it. I don't want it to be related with my actual account.

I don't think a greeting bot is a great idea.

To make a new account, try vessel or anonsteem.

thanks for the answer

Will need this later. Thanks

Thanks, @felixx I was looking for these kinda post.

Thank you very much for this newbie guide! It's a great introduction!

i got this error :

scrypt-1.2.0/libcperciva/crypto/crypto_aes.c:6:10: fatal error: openssl/aes.h: No such file or directory
#include <openssl/aes.h>
^~~~~~~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------

Command "/usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-s289xalf/scrypt/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-tgmq4xaz-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-s289xalf/scrypt/

is any way to make with windows7 operating system because i am trying to search but not getting anywhere.

Yeah it's not as easy as described above anymore.
For Steem-Python I'd recommend installing a Linux-VM in Windows.