create account

How can I make steembottracker's front run the bots with python by hakancelik

View this thread on: hive.blogpeakd.comecency.com
· @hakancelik · (edited)
$0.74
How can I make steembottracker's front run the bots with python
#### Repository
https://github.com/MattyIce/bottracker

#### What Will I Learn?

Hello everyone Let's start today I'll show you how to make steembottracker's front run the bots with python this project name is firstup, thank you to @yasujizr who found the name of this project and idea of this project me ( @hakancelik ) and @captainsailor thank you cap.

- You will learn python functions
- You will learn steem-python library
- You will learn requests and json python library
- You will learn getting data from the internet with python

#### Requirements

- python 3.6
- [steem-python library](https://github.com/steemit/steem-python)

#### Difficulty

- Basic

#### Tutorial Contents

<center> ![](https://steembottracker.com/img/header_logo.png)
<sub>[Source ](https://steembottracker.com)</sub></center>

------


## Let's start 
#### 1- Create a file called settings.py

first we create a file called settings.py , into this file we will write our small settings for our bot.


```
from steem import Steem

class Keys:
    accounts = [
        {"username":"username","weight":100,"min_bid":20,"voting_power":80,"posting_key":"posting_key"},
    ]
    
    keys = [account["posting_key"] for account in accounts]

STEEM = Steem(nodes=['https://api.steemit.com'],keys = Keys.keys)

MINUTE_MAX = 32

MINUTE_MIN = 30
```

let me explain the codes

- we first included our Steem library into our project 
- and created a class called Keys ,purpose of this class enter the accounts and some accounts' information.
- You can add as many accounts as you want to the accounts variable
- On this line ( STEEM = Steem(nodes=['https://api.steemit.com'],keys = Keys.keys))
    We have set up the steem node and assigned the account keys
- minute settings means that the minimum and maximum minutes information for our upvote

--------

#### 2- Create a file called main.py

- first we will use it in our project and add libraries and variables.

```
from steem.post import Post
from steem.account import Account

import requests
import json
import time
from datetime import datetime, timedelta

from settings import STEEM,Keys,MINUTE_MAX,MINUTE_MIN
```
- we will use API to attract bids sent to bots, [steembottracker api](https://steembottracker.net/posts)

write a function for it name get_bids

```
def get_bids():
    steembottrackerurl = "https://steembottracker.net/posts"
    r = requests.get(steembottrackerurl)
    for i in r.json():
        yield dict(
        amount = i["amount"],
        currency = i["currency"],
        author = i["author"],
        permlink = i["permlink"],
        )
```

- Now it's time to code up to get upvote

```
def upvote(post):
    voters_list = [i["voter"] for i in STEEM.get_active_votes(post.author, post.permlink)]
    post_url = "@"+post.author+"/"+post.permlink
    voted = {}
    for account in Keys.accounts:
        username = account["username"]
        weight = float(account["weight"])
        output = {"status":False,"user":username,"note":"already voted","post_url":post_url}
        try:
            post.vote(weight,username)
            output.update(status = True,note = "voted")
        except:
            output.update(note = "Unknown")
        yield output
```

- and the last part that sends the upvote request, which looks at incoming offers, accounts, share times.

```
def run():
    ready_users = []
    for user in Keys.accounts:
        user_voting_power = Account(user["username"], steemd_instance = STEEM).voting_power()
        print("user_voting_power",user["username"],user_voting_power)
        if user_voting_power > user["voting_power"]:
            ready_users.append(user)
    for bid in get_bids():
        for user in ready_users:
            if float(bid["amount"]) >= user["min_bid"]:
                post_url = "@"+bid["author"]+"/"+bid["permlink"]
                post = Post(post = post_url, steemd_instance = STEEM)
                post_time_elapse = post.time_elapsed()
                days = post_time_elapse.days
                seconds = post_time_elapse.seconds
                minute = round(seconds/60,4)
                if days == 0:
                    print(user["username"],minute,post_url)
                    if MINUTE_MAX < 32 and MINUTE_MIN >= 30:
                        for up in upvote(post):
                            yield up
```

#### Result

<center>![](https://resmim.net/f/pU9pYy.jpg?nocache)</center>

#### Proof of Work Done

https://github.com/hakancelik96/firstup
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 45 others
properties (23)
authorhakancelik
permlinkfirstup-how-can-i-make-steembottracker-s-front-run-the-bots-with-python
categoryutopian-io
json_metadata{"tags":["utopian-io","tutorial","python","steem"],"users":["yasujizr","hakancelik","captainsailor"],"image":["https://steembottracker.com/img/header_logo.png","https://resmim.net/f/pU9pYy.jpg?nocache"],"links":["https://github.com/MattyIce/bottracker","https://github.com/steemit/steem-python","https://steembottracker.com","https://api.steemit.com","https://steembottracker.net/posts","https://github.com/hakancelik96/firstup"],"app":"steemit/0.1","format":"markdown"}
created2018-06-15 20:07:12
last_update2018-06-16 09:40:51
depth0
children10
last_payout2018-06-22 20:07:12
cashout_time1969-12-31 23:59:59
total_payout_value0.640 HBD
curator_payout_value0.099 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,476
author_reputation15,102,487,166,852
root_title"How can I make steembottracker's front run the bots with python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id60,898,961
net_rshares295,891,426,399
author_curate_reward""
vote details (109)
@amosbastian ·
Is this meant to be a tutorial?
properties (22)
authoramosbastian
permlinkre-hakancelik-firstup-how-can-i-make-steembottracker-s-front-run-the-bots-with-python-20180615t233039448z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-06-15 23:30:39
last_update2018-06-15 23:30:39
depth1
children5
last_payout2018-06-22 23:30:39
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_length31
author_reputation174,473,586,900,705
root_title"How can I make steembottracker's front run the bots with python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id60,915,478
net_rshares0
@hakancelik ·
partly, I wanted to teach you a little that I developing so it is development but at the same time  tutorial content ,Is it a bad idea ?
properties (22)
authorhakancelik
permlinkre-amosbastian-re-hakancelik-firstup-how-can-i-make-steembottracker-s-front-run-the-bots-with-python-20180615t233822112z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-06-15 23:38:21
last_update2018-06-15 23:38:21
depth2
children4
last_payout2018-06-22 23:38:21
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_length136
author_reputation15,102,487,166,852
root_title"How can I make steembottracker's front run the bots with python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id60,916,051
net_rshares0
@amosbastian ·
I think this is probably best suited to the tutorial category, but you would more than likely need to change some things to suit that category's guidelines (but it's up to you if you want to keep it as a development contribution).
properties (22)
authoramosbastian
permlinkre-hakancelik-re-amosbastian-re-hakancelik-firstup-how-can-i-make-steembottracker-s-front-run-the-bots-with-python-20180615t235103922z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-06-15 23:51:03
last_update2018-06-15 23:51:03
depth3
children3
last_payout2018-06-22 23:51:03
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_length230
author_reputation174,473,586,900,705
root_title"How can I make steembottracker's front run the bots with python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id60,916,960
net_rshares0
@minnowsupport ·
<p>Congratulations!  This post has been upvoted from the communal account, @minnowsupport, by hakancelik from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows.  Please find us at the <a href="https://discord.gg/HYj4yvw"> Peace, Abundance, and Liberty Network (PALnet) Discord Channel</a>.  It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.</p> <p>If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=102530.639667%20VESTS">50SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=205303.639667%20VESTS">100SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=514303.639667%20VESTS">250SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=1025303.639667%20VESTS">500SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=2053030.639667%20VESTS">1000SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=10253030.639667%20VESTS">5000SP</a>. <br><strong>Be sure to leave at least 50SP undelegated on your account.</strong></p>
properties (22)
authorminnowsupport
permlinkre-firstup-how-can-i-make-steembottracker-s-front-run-the-bots-with-python-20180615t203950z
categoryutopian-io
json_metadata"{"app": "beem/0.19.23"}"
created2018-06-15 20:39:51
last_update2018-06-15 20:39:51
depth1
children0
last_payout2018-06-22 20:39:51
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_length1,706
author_reputation148,902,805,319,183
root_title"How can I make steembottracker's front run the bots with python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id60,901,820
net_rshares0
@portugalcoin ·
Thank you for your contribution.

- Doesn´t follow the template for tutorials. See the template <a href="https://github.com/utopian-io/editor-templates/blob/master/tutorials">here</a>.

See in this <a href="https://steemit.com/utopian-io/@espoem/make-your-posts-look-great-in-steemit-and-busy">link</a> an example of a good tutorial.

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
properties (22)
authorportugalcoin
permlinkre-hakancelik-firstup-how-can-i-make-steembottracker-s-front-run-the-bots-with-python-20180616t011412786z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"links":["https://github.com/utopian-io/editor-templates/blob/master/tutorials","https://steemit.com/utopian-io/@espoem/make-your-posts-look-great-in-steemit-and-busy","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2018-06-16 01:14:12
last_update2018-06-16 01:14:12
depth1
children1
last_payout2018-06-23 01:14:12
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_length503
author_reputation604,275,985,631,545
root_title"How can I make steembottracker's front run the bots with python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id60,922,815
net_rshares0
@hakancelik ·
This is my first tutorial content ,I edited the tutorial,Is there any possibility of reviewing the content again ?
properties (22)
authorhakancelik
permlinkre-portugalcoin-re-hakancelik-firstup-how-can-i-make-steembottracker-s-front-run-the-bots-with-python-20180616t092618296z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-06-16 09:26:18
last_update2018-06-16 09:26:18
depth2
children0
last_payout2018-06-23 09:26:18
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_length114
author_reputation15,102,487,166,852
root_title"How can I make steembottracker's front run the bots with python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id60,959,555
net_rshares0
@steemitboard ·
Congratulations @hakancelik! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

[![](https://steemitimages.com/70x80/http://steemitboard.com/notifications/posts.png)](http://steemitboard.com/@hakancelik) Award for the number of posts published

<sub>_Click on the badge to view your Board of Honor._</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>


To support your work, I also upvoted your post!


**Do not miss the [last post](https://steemit.com/steemitboard/@steemitboard/steemitboard-world-cup-contest-croatia-vs-nigeria) from @steemitboard!**

---
**Participate in the [SteemitBoard World Cup Contest](https://steemit.com/steemitboard/@steemitboard/steemitboard-world-cup-contest-collect-badges-and-win-free-sbd)!**
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: [@good-karma](https://v2.steemconnect.com/sign/account-witness-vote?witness=good-karma&approve=1) and [@lukestokes](https://v2.steemconnect.com/sign/account-witness-vote?witness=lukestokes.mhth&approve=1)

---

> Do you like [SteemitBoard's project](https://steemit.com/@steemitboard)? Then **[Vote for its witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1)** and **get one more award**!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-hakancelik-20180616t022232000z
categoryutopian-io
json_metadata{"image":["https://steemitboard.com/img/notify.png"]}
created2018-06-16 02:22:30
last_update2018-06-16 02:22:30
depth1
children0
last_payout2018-06-23 02:22:30
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_length1,340
author_reputation38,975,615,169,260
root_title"How can I make steembottracker's front run the bots with python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id60,928,115
net_rshares0