Reputation Bot
Reputation bot
This improved version of @furion's bot
You will need:
Python3: https://www.python.org/downloads/
Piston: http://piston.readthedocs.io/en/develop/installation.html
I'm using pm2 to restart bot when it crashes.
Here is process.json for pm2:
{
"apps" : [{
"name" : "bot",
"script" : "./bot.py",
"watch" : true,
"interpreter" : "/usr/local/bin/python3",
"interpreter_args": "-u"
}]
}
Here is bot. Copy this code to file named: bot.py
Edit ACCOUNT and POSTING_KEY constants.
from piston.steem import BroadcastingError
import threading
import time
from datetime import datetime
import random
from pprint import pprint
ACCOUNT = "<account>"
POSTING_KEY = "<posting key in wif format>"
VOTE_DELAY = 1770 # 29 minutes and 30 seconds
VOTE_WEIGHT = 100
MIN_REPUTATION = 7462599456169 # about 59 rep on steemit
# MIN_REPUTATION = 10046968152082 # about 61 rep on steemit
comment_history = {}
def feed():
print("Waiting for new posts with high reputation")
steem = Steem(wif=POSTING_KEY, node="wss://node.steem.ws")
for comment in steem.stream_comments():
if int(comment.author_reputation) < MIN_REPUTATION:
continue
# Comments don't have titles. This is how we can know if we have a post or a comment.
if len(comment.title) == 0:
continue
# check if we already upvoted this. Sometimes the feed will give duplicates.
if comment.identifier in comment_history:
continue
# exclude updates to posts
if comment.created_parsed != comment.last_update_parsed:
continue
comment_history[comment.identifier] = True
print("[%s][NEW POST] %s" % (time_now(), 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 time_now():
now = datetime.now()
return now.strftime("%d.%m.%Y %H:%M:%S")
def worker(worker_comment):
time.sleep(VOTE_DELAY)
try:
worker_comment.vote(VOTE_WEIGHT, ACCOUNT)
comment_history.pop(worker_comment.identifier, None)
print("[%s][UPVOTED] %s" % (time_now(), url_builder(worker_comment)) )
except BroadcastingError as e:
print("[%s][UPVOTE FAILED] %s" % (time_now(), url_builder(worker_comment)) )
print(str(e))
if __name__ == "__main__":
while True:
try:
feed()
except (KeyboardInterrupt, SystemExit):
print("\nQuitting...")
break
except Exception as e:
traceback.print_exc()
print("### Exception Occurred: Restarting...")
Starting bot using pm2:
pm2 start process.json
Without pm2:
python3 bot.py
Can you update this bot https://steemit.com/steem/@complexring/steem-autovote-bot