Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions api/buff/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ def get_best_offer_for_item_list(self, names: List[str]) -> List[Item]:
def create_cookies(self):
# TODO: Replace with custom loading cookies since these need to be replaced regularly
return {
"Device-Id": "ZXeO6pQgFmJ2w1aryQf7",
'Device-Id': 'l40vB6x92paqjkhfYVqc',
'Locale-Supported': 'en',
'session': '1-1xRYWCTSO4oCdoh_2Iux2L9n7Ymajsniy8CTzgIhM31c2032647117',
'game': 'csgo',
'session': '1-hUgTR7Fip4NKzLmvl-GbdCehT4T6_3SQBb5CJs1IPqzZ2032647117',
'client_id': 'xgl9XGnPqh1x7-gdtmaxGg',
'display_appids': '"[730\\054 570]"'
'csrf_token': 'ImZiZWUxY2I0ZDkyZTU5ZGYzMmY3N2U2ZTkwZjY0YjE1NWI4Y2U1Yzgi.F0to5A.ej3puC3GTHTOHNXGAIfus7L7wnU',
}

def get_items_from_buff(self, item: Item):
Expand Down Expand Up @@ -112,6 +111,44 @@ def delete_buy_offer(self, buy_offer_id: str):
def get_buy_offers(self):
raise NotImplemented()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw away

def accept_sell_offer(self):
headers = {
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Language': 'de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7,uk;q=0.6,af;q=0.5',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
# 'Cookie': 'Device-Id=l40vB6x92paqjkhfYVqc; Locale-Supported=en; session=1-1xRYWCTSO4oCdoh_2Iux2L9n7Ymajsniy8CTzgIhM31c2032647117; game=csgo; csrf_token=ImZiZWUxY2I0ZDkyZTU5ZGYzMmY3N2U2ZTkwZjY0YjE1NWI4Y2U1Yzgi.F0tooA.69xp-N3PpOFuGTOMyRd_lOs7InY',
'Pragma': 'no-cache',
'Referer': 'https://buff.163.com/market/sell_order/to_deliver?game=csgo',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36',
'X-Requested-With': 'XMLHttpRequest',
'sec-ch-ua': '"Google Chrome";v="113", "Chromium";v="113", "Not-A.Brand";v="24"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
}
params = {
'_': str(int(time.time() * 1000)),
}
response = requests.get('https://buff.163.com/api/market/steam_trade', params=params, cookies=self.create_cookies(),
headers=headers).json()
dataBody = []
for x in response['data']:
assetList = []
for y in x['items_to_trade']:
assetList.append(y['assetid'])
goodsID = x['items_to_trade'][0]['goods_id']
#ToDo Here TradeOffer akzeptieren
print("Offer here: https://steamcommunity.com/tradeoffer/" + str(x['tradeofferid']))
keys = ["tradeofferid", "Item", "amount", 'assets', "status"]
values = [x['tradeofferid'], x['goods_infos'][str(goodsID)]['market_hash_name'], len(x['items_to_trade']),
assetList, "offer accepted - check if trade succeed"]
dataBody.append(dict(zip(keys, values)))

return dataBody

def get_closed_buy_offers(self):
raise NotImplemented()

Expand Down
7 changes: 3 additions & 4 deletions database/handler/updateTargets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from api.marketplace import Item
from api.dMarket import api as dMarketApi
from database.createDatabase import csgo_cur
from database.createDatabase import csgo_cur, csgoDB

last_offer_id: str

Expand All @@ -14,10 +14,8 @@ def update_buy_offers():
time1 = round(time.time(), 1)
for buy_offer in closed_buy_offers:
t = csgo_cur.execute(
'SELECT COUNT(*) FROM buy WHERE buy_id_3p ="' + buy_offer.asset_id + '"').fetchone()[0]

'SELECT COUNT(*) FROM buy WHERE buy_id_3p ="' + buy_offer.offer_id + '"').fetchone()[0]
if t == 0:
print(buy_offer.name)
def_index = \
csgo_cur.execute('SELECT def_index FROM item_basis WHERE itemName="' + buy_offer.name + '"').fetchone()[0]
print(def_index)
Expand All @@ -29,3 +27,4 @@ def update_buy_offers():

csgo_cur.execute('INSERT INTO buy VALUES (?,NULL,?,?,?,?)',
(internal_id, buy_offer.offer_id, buy_offer.price, buy_offer.on_market.name, time1))
csgoDB.commit()
4 changes: 1 addition & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@


def main():

# Create database if not available or if env is set
if (not os.path.isfile("CSGO.db")) or (bool(os.getenv('DATABASE_RESET'))):
if (not os.path.isfile("CSGO.db")) or (os.getenv('DATABASE_RESET') == 'true'):
print("Created new Database")
createDatabase.createDatabase()

update_buy_offers()

if __name__ == '__main__':
Expand Down