用程序收取指定账户的收益 / Claim rewards from the specified account by scripts

用程序收取指定账户的收益 / Claim rewards from the specified account by scripts

在好久之前,我曾写过一篇文章How to claim your rewards automatically? / 如何自动收取你的收益,这个脚本很简单,我将其设置到crontab里,帮我自动Claim每天的奖励。


(图源 :pixabay)

虽然这个脚本工作良好,但是偶尔我也需要手动claim一下账户的收益,以往steemit网站和steemit钱包在一起的时候,我只需登录网站然后进入钱包页面,点一下Claim就好。

可是自从steemit网站和steemit钱包分离,这个操作就变得相当繁琐,我要重新登录一下钱包网站然后输入密码,再进行操作。

所以我简单改造了一下之前的脚本,让其更适合在命令行使用。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python
import click
from steem import Steem

@click.command()
@click.argument('account')

def claim_reward(account):
steem=Steem()
try:
user_info = steem.get_account(account)
reward_sbd = float(user_info['reward_sbd_balance'].split(' ')[0])
reward_steem= float(user_info['reward_steem_balance'].split(' ')[0])
reward_vesting = float(user_info['reward_vesting_balance'].split(' ')[0])
reward_sp = float(user_info['reward_vesting_steem'].split(' ')[0])

if reward_sbd > 0 or reward_steem > 0 or reward_vesting > 0:
steem.claim_reward_balance(account = account)
print(f"{account} Claimed rewards: {reward_steem} STEEM {reward_sbd} SBD {reward_sp} STEEM POWER")
else:
print('No rewards need to be claimed: {}'.format(account))
except:
print("Error occured!")
raise

if __name__ == "__main__":
claim_reward()

使用起来极其简单:

./claim.py oflyhigh

与之前的脚本相比,这个会简单的打印出收取到的奖励的数量,比如:

如果没有奖励可以收取,也会提示:

另外,一些相关技术背景以及如何设置steem-python以及私钥等内容,请参考文末链接,我就不再赘述了。

编码水平有限,如有谬误,请及时指正,深表谢意。

相关链接


Vote For Me As Witness
https://steemit.com/~witnesses type in oflyhigh and click VOTE

Vote @oflyhigh via Steemconnect
Thank you!

This page is synchronized from the post: ‘用程序收取指定账户的收益 / Claim rewards from the specified account by scripts’

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×