I Updated an Upvote Bot and I'm Giving It Away

in #steemit8 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
Sort:  

to start the bot
screen upvote
while :; do python3 upvote_bot.py; sleep 5; done
screen -r upvote
ctrl a + d to close

I want a bot to follow me and tell me that my hair looks nice today after it upvotes me. :P

@sweet-talker would be lovely. a real ladies bot!

I can be your boy.... umm, I mean bot. You look nice today. Have a great day.

Thank you for sharing!

Thanks for sharing. I will try to set it up... i am with little time now, but i really want this kind off tool, but i will need to achiev some basic knowledge to do this. But no worry... the important thing you just have shared.

nice work.. keep going.

Steemvoter does the same and is simpler and there's even free site for it, but it is not the solution of bad SP distribution.

I'm sure there are better scripts out there. @proctologic requested a small tweak to this one so I learned to thread in Python :) @furion has moved on to SteemQ so this script won't be getting much more attention in the future.

Do you mean Steemian for the free site? That one is run by @xeroc and is great but it needs you to use your active keys which some people don't like.

No, I meant steemvoter.com

Damn, I wish my computer guru son was around to help me figure out how to use this thing. Thank you for sharing.

Maybe one day, if I have enough steem power. But on a more positive note, the robot with coffee pic made me realize I didn't have coffee yet this morning, gonna go get coffee now.

I disapprove of gaming the system.
I'm seriously considering flagging.

Why do you think this is gaming the system? Unlike some people here, I'm not going to jump down your throat when you say why you think it - I'm honestly curious why you think upvote bots are unethical.

Consider it as subscribing to your favorite authors. You want them to keep writing so you reward them, but you can't be online 24/7 and you also like to get max profit for your vote so this is where automation can help.

Actually the system encourages this type of thing. Take a look at services like Streemian.com made by none other than a leading developer of bitshares and steem @xeroc it helps automate your voting. There is also proxy voting built into the system too. Steemit encourages you automating your votes by attaching it to trusted accounts.

You still have to pick the authors you trust with your vote. Also I might add this is merely an update to @furion's already popular script.

can you make it upvote my posts? :O

ofc. follow me upvote me and approve my witness.

I can follow and upvote, no clue how to approve witness. :O

Loading...

Did you know that flagging this post would damage the author's reputation across the board and hurt his business here on Steemit? Disapproving of content is not reason enough to flag. Flagging is for inappropriate content. It is really NOT a down vote button.

As another person who would sincerely like to know why you are against automation, would you mind telling us why. Bots are used on Ebay to place bids at the last second, the stock market uses automation and so do many, many other systems. Computers are supposed to make our lives easier, more efficient and reduce errors. Using them to do these things for us allows us to focus on more important things that computers can't do.

I was actually thinking of building a website that would allow people to do this very thing. Add a list of their favorite authors and what time they would like to post to their articles. Is this something that you would be against?

What is the purpose for the 30 minute delay?

You can find a lot of information in the white paper. Basically, the 30 min delay is to limit bots gaming the system. I don't think it worked though and just made it more difficult for everyone to use the platform effectively. The 30 min delay is actually a great reason to use a bot so that you don't forget to vote.

We should build some bots that create content, then we can pit content creation bots against the upvote bots. Steem can use these bots to replace the people who leave.

Everybody is welcome to use our service @litasio.

@dicebot what do you think of this dicebot? 1D6

Dice Bot Rolled : 4