How can I make steembottracker's front run the bots with python
utopian-io·@hakancelik·
0.000 HBDHow 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>  <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></center> #### Proof of Work Done https://github.com/hakancelik96/firstup
👍 murattatar, snackaholic, steemitstats, yuxi, steemit-turkey, mlekotosamozlo, yasujizr, minnowsupport, kujou, tdre, leir, st3llar, mahsumclkblk, yorkchinese, jaff8, steemitboard, hakancelik, coogger, hardrockebab, jun04035, puffin, onejoe, neneandy, waltliquor, saoirseronan, xee95, veerall, strefanetu, mashwanii, mrwildenfree, ews, neru, fisker, robertmannino, afrosiab, dongentle2, colicoid, jospig, italianguy, inspectorschelle, daniel-irala, xsorbik, morice, cryptoscout, cwen, hoangmanhcuong, silasdavid, sarmins, witnesess.doo, crcs2o4, geniusmind, ajcordenete, nairamallam, zaggysteem, nicolelang, nikkicole, bigboycrafts, fireonxas, yemi90210, paquetedecuba, learnandteach01, achmadyani, maddieseal, sawyn, shuler, vaquita, sudi, pepe7777, evanpetzer, yahqan, inspiredgideon1, rexlito, ivan78, mrelliwood, mrblu, susano, coral-reef, sisirhasan, paramon, samiun, astrizak, nikita.pobazhak, jibupune, riesaxon, strategema, didiblack, autumnflower, tethre, radikal, thecottage.che, peuhaba2020, tilenpirih, aro.steem, simba20, thecryptopreneur, anikpaul52, jason.che, fishhead, zamazingo1898, rockymtnsteem, albatar, joserafaelhf, toni2oni, konradxxx3, charliekerper, cebunick, engrbrain1, raci, delphia16,