Is it ethical to use bots for post voting? I've decided that it is not bad to automatically support authors, which I follow and whose articles I like to read. I'm not every day surfs on steemit.com, but with the bot I could upvote the articles in time, not miss it and read lately.
I know about SteemVoter project by @marcgodard and I saw a couple similar scripts (votum by
@clayop, steem-autovote-bot by
@complexring, radiator by
@inertia, Steem-FOSSbot by
@personz). I'm not aim for vote posts which could yield maximal profit. My voting bot is just a coding for fun project.
First of all, I thought how could I technically solve this task based on my own knowledge. It seems to me, that easy to write several small Python scripts to process separately different parts of the task and use Redis DB as a common values storage. I eager to see my own ideas are working.
Steem_follow
Configuration parameters are stored in steem_up.yml local YAML-file, which contains a list of authors you are follow. The steem_follow.py script read config at start-up and begin to retrieve last posts from Steem blockchain ("piston-lib" module is used). If the post author is on the following list, the post data stored in a Redis database till expired. A hash of a post body is used as a key in Redis DB. In order to distinguish initial post from post edition (only diff is usually posted after edition), the script check first symbols in the body:
if operation[1]["author"] in following and \ # author is on the list
operation[1]["parent_author"] == "" and \ # not a comment
operation[1]["body"][0:2] != "@@": # not a diff
but sometimes after initial post it is possible to send edited body instead of diff.
That is all the script is doing. After processing a number of blocks the script is going to sleep for timeout.
Steem_up
The upvote process is handled by steem_up.py script. The script get a list of posts to upvote from Redis DB with appropriate time-stamps. If configured time from posting is lasted and upvote rate limit is not exceeded, the script send upvote to the blockchain. To securely store Steem posting key on VPS, posting key is encrypted by encrypt3.py script. The password for the key decryption is only entered in console during steem_up.py start every time. After upvoting a bunch of post the script go to sleep as well.
Steem_limit
The steem_limit.py script is running every 1 hour by cron. Configured voting rate limit is controlling maximal voting per day. I use "token bucket" algorithm to limit automatic voting. For example, I delegate to my vote-bot 15 upvotes per day. So, the limit is stored in database and when my bot make a vote the value is decreasing by 1. At the same time, the script every 1 hour increase the limit (or generate new tokens to bucket) on 15/24 till maximal value 15. When the limit is 0 (the bucket is empty), there is no new votes by steem_up.py script. Also steem_limit.py removing outdated upvoted posts from DB.
Steem_web
Actually Redis DB master is running on VPS and the database is replicated to a slave node on my Raspberry Pi. So, locally running steem_web.py - is a simple web server (based on Twisted framework with Jinja2 templates) used for bot voting monitoring. I could easily see last upvoted posts and click to the link to steemit.com to read the article:
Steem_upvoted
Once a day steem_upvoted.py script is sending notification to my xmpp-client with short report about bot voting statistics:
For last 24h
12.75 rate limit
15 posts with authors:
thecryptofiend, dana-edwards, calaber24p, crypt0, lukestokes, avtzis.petros, shieha, boxmining
Lately I could add possibility to use vote rules, for example, to vote only with specific tags or not vote for some topics.