Upvote script by tagsteemCreated with Sketch.

in #gridcoin7 years ago (edited)

Sorry for being lazy


I like to take news from Gridcoin and support as much as I can. I know that the Gridcoin community is very active on Steemit, generally I take the time to read and vote. But I'm starting to become more and more lazy... So I helped myself with this post and I made a script to vote for myself.

As you may have noticed, this script retrieves all posts associated with Gridcoin, upvote each one, adds it to a text file, and wait a little before voting on another post.

Use the script as you like !

Btw, you'll need Python3 and Piston to run it.

import time
import traceback
from typing import List
from piston import Steem
from pistonapi.exceptions import AlreadyVotedSimilarily

# put your details here 
# find it in Wallet/Permissons
account = ""
posting_key = ""

# waiting after voting (wait in seconds), 
# trying to maximize the vote weight (and avoid NotEnoughtVoteWeight)
vote_delay = 100
# file with each post identifier
history_file = "upvoted.txt"
# number of the posts fetched in one call : 100 MAX
number_of_posts = 50
# sorting : ["trending", "created", "active", "cashout", "payout", "votes", "children", "hot"]
sorting = "created"
# the given tag to fetch posts
tag = "gridcoin"


def feed():
    # if you liked my script, uncomment the next line ;)
    # send_a_tip(@chronosamoht)
    print("Waiting for new posts in tag %s\n" % tag)
    steem = Steem(wif=posting_key, node="wss://this.piston.rocks")
    all_posts = steem.get_posts(number_of_posts, sorting, tag)

    history = load_history()
    for post in all_posts:
        print("upvote :", "https://steemit.com/" + post.identifier)
        if post.identifier not in history and worker(post):
            time.sleep(vote_delay)


# 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 load_history() -> List[str]:
    with open(history_file) as file:
        content = file.readlines()

    return [x.strip() for x in content]


def save_upvoted_posts(text):
    with open(history_file, "a") as file:
        file.write("\n" + text)


def worker(worker_comment):
    try:
        worker_comment.vote(100, account)
        print("====> Upvoted")
        save_upvoted_posts(worker_comment.identifier)
        return True
    except AlreadyVotedSimilarily as e:
        save_upvoted_posts(worker_comment.identifier)
        print("Upvoting already done...")
        return False
    except Exception as e:
        print("Upvoting failed...")
        print("We have probably reached the upvote rate limit.")
        print(str(e), type(e))
        time.sleep(vote_delay * 2)
        return False


if __name__ == "__main__":
    while True:
        try:
            feed()
        except (KeyboardInterrupt, SystemExit):
            print("Quitting...")
            break
        except Exception as e:
            traceback.print_exc()
            print("### Exception Occurred: Restarting...")

That's all folks !

Feel free to follow !

grid

Sort:  

You should perhaps set a minimum reputation, because bots/spammers may include the 'gridcoin' tag just to get your upvote despite their post having nothing to do with gridcoin.

Great work though, keep it up :D

Probably not that worth it if they are flaged enough. Anyway, good call !

Congratulations @chronosamoht! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Congratulations @chronosamoht! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Coin Marketplace

STEEM 0.21
TRX 0.25
JST 0.039
BTC 98660.01
ETH 3484.72
USDT 1.00
SBD 3.23