Updated an Upvote Bot and I'm Giving It Away

in steemit •  7 years ago 

I was hanging out on Steemspeak the other day. Someone mentioned they had a really nice upvote bot but wished it could wait 30 minutes before upvoting the people it followed. By waiting 30 minutes they could earn curation rewards with their upvotes.

I've been playing around with Piston and the Steem Python library in an effort to learn more Python coming from a PHP/Java background myself. You can read about my previous efforts learning Python with a simple Steemit bot here Learning Python, A Simple Python Script to Import Steemit Data Into MySQL or Learning Python by Making a Steemit Bot. I thought this would present an excellent opportunity to learn a bit about how Python handles multi-threading.

The original script that I modified was created by @furion and can be found here I Made and Upvote Bot and I'm Giving it Away . The script has two types of people you can add there are top writers and my favorites. Top writers will receive an upvote from you when they publish a post and My Favorites will receive an upvote as well as a $2 SBD tip. If you don't want to send any SBD then don't add your active key and don't add anyone to the My Favorites list. You can just use the Top Writers.

Save the following to a file named upvote_bot.py and update the information section at the top with your information and usernames you want to upvote and tip.

from piston.steem import Steem
from piston.steem import BroadcastingError
import threading
import time
import random

my favorite blogs on steemit

top_writers = ["ned", "contentjunkie", "dantheman", "furion"]

add my favorites

shoutout to my lil sister @mwpower, she loves to write but gets discouraged fast

my_favorites = ["contentjunkie"]

my_subscriptions = top_writers + my_favorites

#put your details here only put the active key if you want to tip people in your favorites list
account = ""
posting_key = ""
active_key = ""
#the number of seconds to wait after a post is published before you vote 1800 seconds = 30 minutes
vote_delay = 1800

upvote_history = []

def feed():
print("Waiting for new posts by %s\n" % my_subscriptions)
steem = Steem(wif=posting_key, node="wss://node.steem.ws")
for comment in steem.stream_comments():

    if comment.author in my_subscriptions:
        # Comments don't have titles. This is how we can know if we have a post or a comment.
        if len(comment.title) > 0:

            # check if we already upvoted this. Sometimes the feed will give duplicates.
            if comment.identifier in upvote_history:
                continue

            print("New post by @%s %s" % (comment.author, url_builder(comment)))
            workerThread = threading.Thread(name=comment.identifier, target=worker, args=(comment,))
            workerThread.start()

send $2 in SBD

def send_a_tip(author):
steem = Steem(wif=active_key)
steem.transfer(author, 2.0, "SBD", memo="I love your blog. Here is a small gift for you.", account=account)

def url_builder(comment):
return "https://steemit.com/%s/%s" % (comment.category, comment.identifier)

def worker(worker_comment):
time.sleep(vote_delay)
try:
worker_comment.vote(100, account)
print("====> Upvoted")
upvote_history.append(worker_comment.identifier)
except BroadcastingError as e:
print("Upvoting failed...")
print("We have probably reached the upvote rate limit.")
print(str(e))

 if comment.author in my_favorites:
   send_a_tip(comment.author)
   print("====> Sent $2 SBD to @%s" % comment.author)

if name == "main":
while True:
try:
feed()
except (KeyboardInterrupt, SystemExit):
print("Quitting...")
break
except Exception as e:
traceback.print_exc()
print("### Exception Occurred: Restarting...")
You will need Python 3 and Piston to run.

python3 upvote_bot.py

SOURCE= https://steemit.com/steemit/@contentjunkie/i-updated-an-upvote-bot-and-i-m-giving-it-away

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 STEEM!
Sort Order:  

Hi! I am a robot. I just upvoted you! I found similar content that readers might be interested in:
https://steemit.com/steemit/@contentjunkie/i-updated-an-upvote-bot-and-i-m-giving-it-away