final version

This commit is contained in:
ovosimpatico
2023-10-10 08:33:51 -03:00
parent cd8cdf7f0d
commit 663c3f2a98
2 changed files with 26 additions and 4 deletions

1
.gitignore vendored
View File

@@ -163,3 +163,4 @@ cython_debug/
#project specific
websocket*
test.json

25
main.py
View File

@@ -1,9 +1,10 @@
import websocket
import datetime
import json
from colr import color
def on_message(ws, message):
print("Data received! Writing it to a file")
# Generate a timestamp for the filename
timestamp = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
filename = f"websocket_{timestamp}.dict"
@@ -11,6 +12,26 @@ def on_message(ws, message):
file.write(message)
print(f"Data written to file {filename}\n")
data = json.loads(message)
SKIN_BUDDY_ID = "ad508aeb-44b7-46bf-f923-959267483e78"
for player_id, player in data['Players'].items():
for weapon_id, weapon in player['Weapons'].items():
if 'skin_buddy' in weapon and weapon['skin_buddy'] == SKIN_BUDDY_ID:
if player['Team'] == "Blue":
print(color(f"Found RGB in player: {player['Name']}", fore='blue', style='bright'))
print("Weapon:", weapon['weapon'])
print("Skin:", weapon['skinDisplayName'])
print()
if player['Team'] == "Red":
print(color(f"Found RGB in player: {player['Name']}", fore='red', style='bright'))
print("Weapon:", weapon['weapon'])
print("Skin:", weapon['skinDisplayName'])
print()
def on_error(ws, error):
print(f"Error: {error}")
@@ -21,7 +42,7 @@ def on_open(ws):
print("Connection established. Waiting for data...\n")
def main():
websocket_url = "ws://localhost:1100" # Replace with the correct WebSocket URL
websocket_url = "ws://localhost:1100"
ws = websocket.WebSocketApp(websocket_url,
on_message=on_message,
on_error=on_error,