· 5 years ago · Jul 25, 2020, 07:28 AM
1import requests
2import steampy
3from steampy.client import Asset
4from steampy.utils import GameOptions
5from steampy.client import SteamClient as sc
6import os
7import json
8from time import sleep
9
10game = GameOptions.CS
11steamguard = 'new_mafile.maFile'
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.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 = {
33 'apikey': apikey,
34 'api_key': api_key,
35 'proxy': proxy_number}
36 ChangeFile('api_keys.json', json_data)
37
38
39def steam_login():
40 global steam_client
41 try:
42 print('Logging to steam account..')
43 steam_client = sc(apikey)
44 print('using ' + str(proxy))
45 steam_client._session.proxies = {'https': str(proxy)}
46 steam_client.login(login, pswd, steamguard)
47 print('Successfully logged in!')
48 except requests.exceptions.ConnectionError:
49 print('Bad proxy')
50 steam_login()
51 except steampy.exceptions.InvalidCredentials:
52 sleep(3)
53 steam_login()
54
55
56def setNewMafile(mafileId64, mafilePathclear):
57 global login
58 Mafile = json.load((open(mafileId64)))
59 steamid = Mafile['Session'].get('SteamID')
60 shared_secret = Mafile.get('shared_secret')
61 identity_secret = Mafile.get('identity_secret')
62 login = Mafile.get('account_name')
63 new_mafile_path = 'new_mafile.maFile'
64 dump_newMafile(mafilePathclear, steamid, shared_secret, new_mafile_path, identity_secret)
65
66
67def dump_newMafile(mafilePathclear, steamid, shared_secret, new_mafile_path, identity_secret):
68 global pswd
69 dataPath = str(mafilePathclear) + str(login) + '.txt'
70 file = open(dataPath)
71 log_pass = file.readline()
72 password = str(log_pass).split(':', maxsplit=2)
73 password2 = str(password[2]).split('\n')
74 pswd = (password2[0])
75 new_mafile = {"steamid": str(steamid),
76 "shared_secret": str(shared_secret),
77 "identity_secret": str(identity_secret)}
78
79 ChangeFile(new_mafile_path, new_mafile)
80
81
82def new_mafile():
83 global pswd, login
84 mafilePath = (os.getcwd())
85 mafileId64 = (os.listdir(path=os.getcwd())[0]) # Получаем мафайл (он должен быть 1 в списке!)
86 mafilePathclear = str(mafilePath).split('maFiles', maxsplit=1)[0] # Получаем путь к папке с данными
87 setNewMafile(mafileId64, mafilePathclear)
88
89
90def getProxy(proxy_number):
91 data = (requests.get('https://proxy-store.com/api/' + api_key + '/getproxy/comment').json())
92 ChangeFile('json.json', data)
93 for proxy in data['list']:
94 comment = data['list'][proxy]['comment']
95 if comment == proxy_number:
96 proxy = 'https://' + str(data['list'][proxy]['user']) + ':' + str(data['list'][proxy]['pass']) + '@' + str(
97 data['list'][proxy]['ip']) \
98 + ':' + str(data['list'][proxy]['port'])
99 return proxy
100
101
102def check_user(agree):
103 if agree == '+':
104 user_id64 = input('Введите id64 человека: ')
105 inventory = steam_client.get_partner_inventory(user_id64, game)
106 balance = 0
107 for x in inventory:
108 itemname = inventory[x]['market_hash_name']
109 price = steam_client.market.fetch_price(itemname, game=GameOptions.CS)
110 print(itemname)
111 print(price)
112 if price['success'] == False:
113 pass
114 else:
115 price = price['lowest_price'].split('USD' and ' ')[0]
116 usd_price = price.split('$')[1]
117 balance += float(usd_price)
118 print('balance: ' + str(balance) + ' usd')
119 sleep(3)
120 agreement = input('Еще?: ')
121 if agreement == '+':
122 check_user('+')
123
124
125proxy = getProxy(proxy_number)
126new_mafile()
127steam_login()
128check_user('+')