create account

Python-Steem Example: Follow Votes by felixxx

View this thread on: hive.blogpeakd.comecency.com
· @felixxx ·
$0.92
Python-Steem Example: Follow Votes
Another example, of how I use py-steem by @xeroc.
This time I'm using the Blockchain class, that was part of steemtools by @furion.

This script will follow votes from authors in a list, called <code>voter_list</code>.
Just replace <code>pk</code> and <code>account</code> with your posting key(s) and account(s).
# Code
    from steem import Steem
    from steem.blockchain import Blockchain
    chain = Blockchain()

    voter_list = ["felixxx"]
    pk = ["5GH56thyouwishlol67zPO9hkO9HKP6gthz8"]
    account = ["votebot"]

    steem = Steem(keys=pk[0], node="wss://node.steem.ws")

    for operation in chain.ops():
        op = operation["op"]
        if op[0] == "vote":
            #print(op) #uncomment this to get an idea of the format
            comment_voter = op[1]["voter"]
            if comment_voter in voter_list:
                comment_link = op[1]["permlink"]
                comment_author = op[1]["author"]
                vote_weight = int(op[1]["weight"]/100)
                comment = steem.get_post("@" + comment_author + "/" + comment_link)
                if comment.is_main_post():
                    print("vote by: " + comment_voter + " for " + comment_link + " weight:" + str(vote_weight)) 
                    for (k,v) in enumerate(account): 
                        try:
                          steem = Steem(keys=pk[k], node="wss://node.steem.ws")
                          comment.vote(vote_weight, v) 
                          print("... followed with " + v + " with " + str(vote_weight) + "%")
                        except Exception as e:
                          print("... NOT followed with " + v + " because:")
                          print(str(e))
___
Known issues: 

- This bot might try to cast multiple votes within too little time ( When multiple accounts in <code>voter_list</code> vote at the same time ) 
___
At the end of the day, this script does nothing more than streemian can already do.
( While streemian is more reliable )

However, I can now try out to take a vote by a trusted author to trigger an event.
Next function I will include is <code>vote_check</code>, like I use for @deutschbot, to see if other trusted authors have already liked the comment, with a <code>treshold</code> from 0-1.
# Code
    def vote_check(c_comment, curators, threshold):
        votercount = 0
        checked = False
        check_comment = steem.get_content(c_comment.identifier)
        for avote in check_comment['active_votes']:
            if (avote['voter'] in curators and avote['percent'] > 0):
                    votercount = votercount + 1            
        vote_ratio = (votercount / len(curators))
            if vote_ratio >= threshold:
            checked = True
        return checked
___
I post these examples, so you have some working examples of code.
Both functions are tested and work.
They are not very clever and might cause some issues, but it's something to build up on.

I don't believe curation should be done with simple algorithms.
I, personally, would maybe deploy the first script, for when I'm on holiday, so I can just follow someone I trust in his curation-efforts.
Mainly, this post is for educational purposes.

<center>http://i.imgur.com/Bhzj9O7.png</center>

I would really appreciate if more people tried this out, so I have someone to talk to, when I run into problems.

# Have fun !
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 54 others
properties (23)
authorfelixxx
permlinkpython-steem-example-follow-votes
categorypython
json_metadata{"tags":["python","py-steem","curation"],"users":["xeroc","furion","deutschbot"],"image":["http://i.imgur.com/Bhzj9O7.png"],"app":"steemit/0.1","format":"markdown"}
created2017-01-27 14:23:30
last_update2017-01-27 14:23:30
depth0
children14
last_payout2017-02-27 15:07:45
cashout_time1969-12-31 23:59:59
total_payout_value0.823 HBD
curator_payout_value0.101 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,374
author_reputation214,877,046,020,983
root_title"Python-Steem Example: Follow Votes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id2,357,595
net_rshares10,511,907,655,524
author_curate_reward""
vote details (118)
@cryptofunk ·
I upgraded python-steem and my old bot stopped working with key errors and all sorts. Luckily I had a snapshot from weeks ago and reverted back. Think the old breed of bots will need to be rewritten :O
👍  
properties (23)
authorcryptofunk
permlinkre-felixxx-python-steem-example-follow-votes-20170127t213511544z
categorypython
json_metadata{"tags":["python"],"app":"steemit/0.1"}
created2017-01-27 21:35:12
last_update2017-01-27 21:35:12
depth1
children7
last_payout2017-02-27 15:07:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length201
author_reputation22,006,702,786,195
root_title"Python-Steem Example: Follow Votes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,360,420
net_rshares14,426,317,349
author_curate_reward""
vote details (1)
@darth-azrael · (edited)
I'm running the latest and bot #1 above doesn't seem to work for me. No errors but it just sits there when I know it should be doing something. However, the older version I had complained about the import blockchain line. Playing around with it, it seems like it is just getting stuck at the "for operation in chain.ops():" line. I double checked my posting key and account but I'm not sure what else to try.

I'm running the winfrey bot and that seems to work ok.
properties (22)
authordarth-azrael
permlinkre-cryptofunk-re-felixxx-python-steem-example-follow-votes-20170127t214606411z
categorypython
json_metadata{"tags":["python"],"app":"steemit/0.1"}
created2017-01-27 21:46:06
last_update2017-01-27 21:47:12
depth2
children5
last_payout2017-02-27 15:07:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length464
author_reputation213,767,279,239,191
root_title"Python-Steem Example: Follow Votes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,360,487
net_rshares0
@felixxx ·
There was a bug, it's fixed now.

You need to clone into the <code>develop</code> branch of py-steem

I should have mentioned that above ...
properties (22)
authorfelixxx
permlinkre-darth-azrael-re-cryptofunk-re-felixxx-python-steem-example-follow-votes-20170127t215631047z
categorypython
json_metadata{"tags":["python"],"app":"steemit/0.1"}
created2017-01-27 21:56:33
last_update2017-01-27 21:56:33
depth3
children0
last_payout2017-02-27 15:07:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length140
author_reputation214,877,046,020,983
root_title"Python-Steem Example: Follow Votes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,360,548
net_rshares0
@felixxx ·
try initializing Steem like this

    Steem(node="wss://node.steem.ws")
properties (22)
authorfelixxx
permlinkre-darth-azrael-re-cryptofunk-re-felixxx-python-steem-example-follow-votes-20170127t230025739z
categorypython
json_metadata{"tags":["python"],"app":"steemit/0.1"}
created2017-01-27 23:00:27
last_update2017-01-27 23:00:27
depth3
children3
last_payout2017-02-27 15:07:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length71
author_reputation214,877,046,020,983
root_title"Python-Steem Example: Follow Votes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,360,912
net_rshares0
@felixxx ·
There was a bug, it's fixed now.

You need to clone into the <code>develop</code> branch of py-steem
properties (22)
authorfelixxx
permlinkre-cryptofunk-re-felixxx-python-steem-example-follow-votes-20170127t215546848z
categorypython
json_metadata{"tags":["python"],"app":"steemit/0.1"}
created2017-01-27 21:55:48
last_update2017-01-27 21:55:48
depth2
children0
last_payout2017-02-27 15:07:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length100
author_reputation214,877,046,020,983
root_title"Python-Steem Example: Follow Votes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,360,543
net_rshares0
@englishtchrivy ·
@felixxx I wish I could but I suck at programming :(
I hope you find someone who'd try this!
properties (22)
authorenglishtchrivy
permlinkre-felixxx-python-steem-example-follow-votes-20170127t202016115z
categorypython
json_metadata{"tags":["python"],"users":["felixxx"],"app":"steemit/0.1"}
created2017-01-27 20:20:09
last_update2017-01-27 20:20:09
depth1
children0
last_payout2017-02-27 15:07:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length92
author_reputation190,105,027,681,254
root_title"Python-Steem Example: Follow Votes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,359,933
net_rshares0
@ervin-lemark ·
@felixxx

Hello. An unrelated comment.

I referred to your old post abou NiceHash [here](https://steemit.com/nicehash/@ervin-lemark/first-payout-at-nicehash-miner). 

Still mining?
properties (22)
authorervin-lemark
permlinkre-felixxx-python-steem-example-follow-votes-20170129t203600524z
categorypython
json_metadata{"tags":["python"],"users":["felixxx"],"links":["https://steemit.com/nicehash/@ervin-lemark/first-payout-at-nicehash-miner"],"app":"steemit/0.1"}
created2017-01-29 20:36:21
last_update2017-01-29 20:36:21
depth1
children3
last_payout2017-02-27 15:07:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length180
author_reputation468,103,602,931,986
root_title"Python-Steem Example: Follow Votes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,374,414
net_rshares0
@felixxx ·
I stopped using nicehash.
I tried mining PASCAL. ( no blocks )
Now I*m not mining at all
properties (22)
authorfelixxx
permlinkre-ervin-lemark-re-felixxx-python-steem-example-follow-votes-20170130t075708695z
categorypython
json_metadata{"tags":["python"],"app":"steemit/0.1"}
created2017-01-30 07:57:09
last_update2017-01-30 07:57:09
depth2
children2
last_payout2017-02-27 15:07:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length88
author_reputation214,877,046,020,983
root_title"Python-Steem Example: Follow Votes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,378,187
net_rshares0
@ervin-lemark ·
:)
properties (22)
authorervin-lemark
permlinkre-felixxx-re-ervin-lemark-re-felixxx-python-steem-example-follow-votes-20170130t080326925z
categorypython
json_metadata{"tags":["python"],"app":"steemit/0.1"}
created2017-01-30 08:03:27
last_update2017-01-30 08:03:27
depth3
children0
last_payout2017-02-27 15:07:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2
author_reputation468,103,602,931,986
root_title"Python-Steem Example: Follow Votes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,378,206
net_rshares0
@smysullivan ·
lol, mining takes a bit to get going, I got old hardware, but it is mining.
👍  ,
👎  
properties (23)
authorsmysullivan
permlinkre-felixxx-re-ervin-lemark-re-felixxx-python-steem-example-follow-votes-20170131t085500403z
categorypython
json_metadata{"tags":["python"],"app":"steemit/0.1"}
created2017-01-31 08:55:00
last_update2017-01-31 08:55:00
depth3
children0
last_payout2017-02-27 15:07:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length75
author_reputation16,261,876,135,297
root_title"Python-Steem Example: Follow Votes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,387,124
net_rshares140,584,268
author_curate_reward""
vote details (3)
@steevc ·
I'll try to have a play at the weekend. I may run a Pi Zero to do this for me. It has a matrix display, so I could show updates on there. Will let you know how I get on.
👍  
properties (23)
authorsteevc
permlinkre-felixxx-python-steem-example-follow-votes-20170127t143554742z
categorypython
json_metadata{"tags":["python"],"app":"steemit/0.1"}
created2017-01-27 14:35:54
last_update2017-01-27 14:35:54
depth1
children0
last_payout2017-02-27 15:07:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length169
author_reputation1,371,148,197,611,199
root_title"Python-Steem Example: Follow Votes"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,357,693
net_rshares69,681,326,374
author_curate_reward""
vote details (1)