コード例 #1
0
ファイル: functions.py プロジェクト: vugluskr86/golos-scripts
def get_voting_power(steem_instance, account):
    """ Calculate real voting power instead of stale info in get_account()
        :param Steem steem_instance: Steem() instance to use when accesing a RPC
        :param str account: account name
    """

    try:
        a = Account(account, steem_instance=steem_instance)
        vp = a.voting_power()
    except Exception as e:
        log.error('error in get_voting_power(): %s', e)
        return False

    last_vote_time = datetime.strptime(a['last_vote_time'],
                                       '%Y-%m-%dT%H:%M:%S')
    elapsed_time = datetime.utcnow() - last_vote_time

    regenerated_power = STEEMIT_100_PERCENT * elapsed_time.total_seconds(
    ) / STEEMIT_VOTE_REGENERATION_SECONDS
    current_power = vp + regenerated_power / 100
    if current_power > 100:
        current_power = 100
    return current_power
コード例 #2
0
def multifeed(puppet, puppet_posting_key):

    upvote_history = []
    pupp = Account(puppet)
    print("{}'s VOTING POWER: {}".format(puppet, pupp.voting_power()))
    vests = str(Account(puppet).get_balances()['VESTS']).split(" ")[0]
    if float(vests) >= 100000:
        vote_weight = 5
    else:
        vote_weight = 100

    if pupp.voting_power() >= 70:
        print("{} : Waiting for new posts by {}".format(
            puppet, my_subscriptions))
        steem = Steem(wif=puppet_posting_key)

        for comment in steem.stream_comments():
            try:
                if comment.author in my_subscriptions:

                    if comment.identifier in upvote_history:
                        print(
                            "Comment has been previously voted on: {}".format(
                                comment.identifier))

                    print("New post by @{} {}".format(comment.author,
                                                      url_builder(comment)))

                    try:
                        print("Voting from {} account".format(puppet))
                        curation_time = random.randint(1800, 2200)
                        dice = random.randint(1, 100)
                        print("Curation time {} for {}, with chance of {}".
                              format(curation_time, puppet, dice))
                        if dice > 77:
                            print("Time to wait {} for {} to vote.".format(
                                curation_time, puppet))
                            t = threading.Thread(
                                target=curation_delay_vote,
                                args=(puppet_posting_key, puppet,
                                      comment.identifier, curation_time,
                                      vote_weight))
                            t.start()
                            upvote_history.append(comment.identifier)
                        else:
                            print("Failed dice:{}".format(dice))
                    except BroadcastingError as e:
                        print("Upvoting failed...")
                        print(
                            "We have probably reached the upvote rate limit. {}"
                            .format(e))
                    except VoteWeightTooSmall:
                        print("Low Vote Weight for: {}".format(puppet))
                        pass
                    except Exception as er:
                        print("Error:{}".format(er))
            except PostDoesNotExist:
                print("Post Does not exist")
                pass

    else:
        print("Skipping vote from {} due to low voting power: {}".format(
            puppet, pupp.voting_power()))
        sys.exit(0)