Files
valorant-riot-buddy/main.py
ovosimpatico bfb6102d2b to folder
2023-10-10 18:35:30 -03:00

54 lines
1.8 KiB
Python

import websocket
import datetime
import json
from colr import color
def on_message(ws, message):
print("Data received!")
timestamp = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
filename = f"data/websocket_{timestamp}.dict"
with open(filename, "w") as file:
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}")
def on_close(ws, close_status_code, close_msg):
print("Connection closed\n")
def on_open(ws):
print("Connection established. Waiting for data...\n")
def main():
websocket_url = "ws://localhost:1100"
ws = websocket.WebSocketApp(websocket_url,
on_message=on_message,
on_error=on_error,
on_close=on_close)
ws.on_open = on_open
ws.run_forever()
if __name__ == "__main__":
main()