This is the basic build of the Prosper bot which will work as an upvoter and curator. The goal of this bot is to help selected minnows with good content.
Here is the first code for the beginning of the bot.py file. This currently allows the bot to upvote based on a list in the votelist.txt file. This file will be populated with lesser-known quality content creators.
from steem.steem import Steem
from steem.steem import BroadcastingError
import threading
import time
import random
import csv
my_subscriptions = []
with open('votelist.txt', mode='r') as infile:
reader = csv.reader(infile)
for rows in reader:
v = rows[0]
my_subscriptions.append(v)
account = ["account_goes_here"]
posting_key = ["password_goes_here"]
vote_delay = random.randrange(1200,1800)
upvote_history = []
def feed():
print("Waiting for new posts by %s\n\n\nGo Oprah!\nGo Winfrey!" % my_subscriptions)
steem = Steem(wif=posting_key[0])
for comment in steem.stream_comments():
if comment.author in my_subscriptions:
if len(comment.title) > 0:
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()
def url_builder(comment):
return "https://steemit.com/%s/%s" % (comment.category, comment.identifier)
def worker(worker_comment):
time.sleep(vote_delay)
try:
for (k,v) in enumerate(account):
worker_steem = Steem(wif=posting_key[k])
upvote_comment = worker_steem.get_content(worker_comment.identifier)
# vote weight 100 full power vote -100 full power flag
upvote_comment.vote(100, v)
print("@%s====> ^Upvoted^" % upvote_comment.author)
upvote_history.append(upvote_comment.identifier)
except BroadcastingError as e:
print("@%s<- failed" % upvote_comment.author)
print(str(e))
if __name__ == "__main__":
while True:
try:
feed()
except (KeyboardInterrupt, SystemExit):
print("Quitting...")
break
except Exception as e:
traceback.print_exc()
print("### Exception Occurred: Restarting...")
More features will be added very soon. This is very basic for now.
Commit URL: https://github.com/nolyoly/prosper-ai/commit/f57a735c36717c23bb571899646bc71b6e99029b
Posted on Utopian.io - Rewarding Open Source Contributors