maxg avatar

Claiming Rewards Tool Snippet

maxg

Published: 08 Feb 2018 › Updated: 08 Feb 2018Claiming Rewards Tool Snippet

Claiming Rewards Tool Snippet

View on SteemBin


#!/usr/bin/env python3

import requests
import click
import sys

unclaimed_msg = """
You have unclaimed rewards on Steemit!
Visit https://steemit.com/@{user}/transfers to redeem:
{sbd:.3f} SBD
{steem:.3f} STEEM
"""

claimed_msg = """
No unclaimed rewards at this time. Check again soon!
"""

error_msg = """
Unable to find a wallet for the user {user}. Please check your spelling and try again.
"""

@click.command()
@click.option('--quiet', is_flag=True)
@click.argument('user')
def check_unclaimed_rewards(user, quiet):
    data = requests.get(f'https://steemit.com/@{user}.json').json()
    if data['status'] == '404':
        if not quiet:
            print(error_msg.format(user=user))
        sys.exit(1)

    pending_sbd = data['user']['reward_sbd_balance'].split(' ')[0]
    pending_steem = data['user']['reward_vesting_steem'].split(' ')[0]

    pending_sbd = float(pending_sbd)
    pending_steem = float(pending_steem)

    if pending_steem > 0 or pending_sbd > 0:
        print(unclaimed_msg.format(**{
            'user':user,
            'sbd': pending_sbd,
            'steem': pending_steem
            }))
    elif not quiet:
        print(claimed_msg)

    sys.exit(0)
    
if __name__ == '__main__':
    check_unclaimed_rewards()

View on SteemBin

Leave Claiming Rewards Tool Snippet to:

Written by

Part time programmer, full time hooligan

Read more #steembin posts


Best Posts From maxg

We have not curated any of maxg's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From maxg