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
Difficulty
- Basic
Tutorial Contents
Source
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
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
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 Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.
If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.
Is this meant to be a tutorial?
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 ?
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).
I think it should be better as tutorial content, what should I change ?
I am not exactly sure as I haven't moderated tutorials in a while, but I would recommend checking out other good tutorials submitted to Utopian.io and reading the guidelines for the tutorial category.
Okey thank you 🙃 I will
Thank you for your contribution.
See in this link an example of a good tutorial.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
This is my first tutorial content ,I edited the tutorial,Is there any possibility of reviewing the content again ?
Congratulations @hakancelik! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Award for the number of posts published
Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word
STOP
To support your work, I also upvoted your post!
Do not miss the last post from @steemitboard!
Participate in the SteemitBoard World Cup Contest!
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: @good-karma and @lukestokes