Introduction
In this series I will share my experience of building a Steemit bot with the python library. I'll post my functions used as a basis for my bot and try to explain it. The final goal will be to develop a high level API build on top of the Steem-Python library to make bot development easy.
Requirements
1. Python 3.6
2. steem-python
I personally use Windows and it was quite challenging to install the library but this tutorial helped me a lot.
The Code
1. Setup
Just like in the last tutorial we need to import the library and initialize the Steem class.
2. The function
The new function get_voter()
basically uses the already existing get_active_votes
function but makes it easier to use.
The old function takes two inputs and we will combine these into one input ("post_identifier") and later split them into two again.
After excuting the function, it returns a list like stated in the offical documentation.
In this example we only want the username of the upvoters but you could also extract other usefull informations like the voting weight.
To isolate this information we need to create a new empty list voter = []
and then add the value of 'voter'
to it, every step of a for loop
.
But before we return the list in the next line we filter out our own upvote in line 13. This will prevent possible further errors with double votes.
3. Execution
The executed function will return a list like this:
As mentioned earlier you only need to provide one argument:
How to get the "post_identifier"
In my first tutorial I already explained how to get the newest post of a user. We can use a faster and updated version of this code to get the "post_identifier" (Thanks to @emrebeyler!).
Final Code (Pastebin.com)
Curriculum
Posted on Utopian.io - Rewarding Open Source Contributors