· 5 years ago · Jun 23, 2020, 05:26 PM
1import requests
2import steampy
3from steampy.client import SteamClient as sc
4from time import sleep
5import json
6import os
7from steampy.utils import GameOptions
8import datetime
9from pycbrf.toolbox import ExchangeRates
10import html5lib
11from steampy.models import Currency
12
13
14def ChangeFile(fileName, Data):
15 with open(str(fileName), 'w') as file:
16 json.dump(Data, file, indent=4)
17 file.close()
18
19
20try:
21 data = json.load((open('api_keys_steam.json')))
22 apikey = data['apikey']
23 api_key = data['api_key']
24 proxy_number = data['proxy']
25
26except:
27 apikey = input('Введите Steam api: ')
28 api_key = input('Введите Proxy store key: ')
29 proxy_number = input('Введите Proxy number: ')
30 agree = input('Запомнить данные? (+/-): ')
31 if agree == '+':
32 json_data = {'apikey': apikey,
33 'api_key': api_key,
34 'proxy': proxy_number}
35 ChangeFile('api_keys_steam.json', json_data)
36 else:
37 json_data = {'apikey': apikey,
38 'api_key': api_key}
39 ChangeFile('api_keys_steam.json', json_data)
40
41steamguard = 'new_mafile.maFile'
42i = 2
43
44
45def steam_login():
46 global steam_client
47 try:
48 print('Logging to steam account..')
49 steam_client = sc(api_key)
50 print('юзаю ' + str(proxy))
51 steam_client._session.proxies = {'https': str(proxy)}
52 steam_client.login(login, pswd, steamguard)
53 print('Successfully logged in!')
54 except requests.exceptions.ConnectionError:
55 print('Bad proxy')
56 steam_login()
57 except steampy.exceptions.InvalidCredentials:
58 sleep(3)
59 steam_login()
60
61
62def del_position():
63 jsonUpd = {"items": []}
64 ChangeFile('position.json', jsonUpd)
65
66
67def setNewMafile(mafileId64, mafilePathclear):
68 global login
69 Mafile = json.load((open(mafileId64)))
70 steamid = Mafile['Session'].get('SteamID')
71 shared_secret = Mafile.get('shared_secret')
72 identity_secret = Mafile.get('identity_secret')
73 login = Mafile.get('account_name')
74 new_mafile_path = 'new_mafile.maFile'
75 dump_newMafile(mafilePathclear, steamid, shared_secret, new_mafile_path, identity_secret)
76
77
78def dump_newMafile(mafilePathclear, steamid, shared_secret, new_mafile_path, identity_secret):
79 global pswd
80 dataPath = str(mafilePathclear) + str(login) + '.txt'
81 file = open(dataPath)
82 log_pass = file.readline()
83 password = str(log_pass).split(':', maxsplit=2)
84 password2 = str(password[2]).split('\n')
85 pswd = (password2[0])
86 new_mafile = {"steamid": str(steamid),
87 "shared_secret": str(shared_secret),
88 "identity_secret": str(identity_secret)}
89
90 ChangeFile(new_mafile_path, new_mafile)
91
92
93def new_mafile():
94 global pswd, login
95 mafilePath = (os.getcwd())
96 mafileId64 = (os.listdir(path=os.getcwd())[0])
97 mafilePathclear = str(mafilePath).split('maFiles', maxsplit=1)[0]
98 setNewMafile(mafileId64, mafilePathclear)
99
100
101def getProxy(proxy_number):
102 data = (requests.get('https://proxy-store.com/api/' + api_key + '/getproxy/comment').json())
103 ChangeFile('json.json', data)
104 for proxy in data['list']:
105 comment = data['list'][proxy]['comment']
106 if comment == proxy_number:
107 proxy = 'https://' + str(data['list'][proxy]['user']) + ':' + str(data['list'][proxy]['pass']) + '@' + str(
108 data['list'][proxy]['ip']) \
109 + ':' + str(data['list'][proxy]['port'])
110 return proxy
111
112
113def first_usd():
114 now = datetime.datetime.now()
115 rates = ExchangeRates(now.strftime("%Y-%m-%d"))
116 usd_price = float(rates['USD'].value)
117 return usd_price
118
119
120def try_usd():
121 global usd_price
122 usd_price = first_usd()
123 if usd_price == None:
124 try_usd()
125 else:
126 pass
127
128
129proxy = getProxy(proxy_number)
130new_mafile()
131try_usd()
132steam_login()
133
134
135def buy_order(percent):
136 item_name = input('Введите имя предмета на который хотите выставить ордер: ')
137 amount = input('Введите кол-во ордеров: ')
138 item_price = steam_client.market.fetch_price(item_name, game=GameOptions.CS)['lowest_price']
139 split_string_us = str(item_price).split('$')
140 item_usd = str(split_string_us[1]).split('USD' and ' ')
141 price = float(item_usd[0]) * float(percent)
142 price = price * usd_price
143 price = round(price, 2)
144 price = price * 100
145 price = round(price)
146 steam_client.market.create_buy_order(item_name, price, int(amount), GameOptions.CS, Currency.RUB)
147 print('good')
148 sleep(3)
149
150
151percent = input('Введите % (формат: 0.n): ')
152
153
154def sing_1():
155 while 5 > 1:
156 try:
157 buy_order(percent)
158 except:
159 print('Error! Try again')
160 sing_1()
161
162sing_1()