From 55ea0af8b1fd1ec4c035f43e328fbb7e881dda8c Mon Sep 17 00:00:00 2001 From: Ollie <69084614+olijeffers0n@users.noreply.github.com> Date: Tue, 27 Jun 2023 15:49:29 +0100 Subject: [PATCH] Fix Facepunch changing something with EXPO, use their endpoint now --- rustplus/__init__.py | 2 +- rustplus/api/remote/expo_bundle_handler.py | 50 ++++++---------------- 2 files changed, 13 insertions(+), 39 deletions(-) diff --git a/rustplus/__init__.py b/rustplus/__init__.py index 6e8ef1e..5d0ad16 100644 --- a/rustplus/__init__.py +++ b/rustplus/__init__.py @@ -22,5 +22,5 @@ __name__ = "rustplus" __author__ = "olijeffers0n" -__version__ = "5.6.6" +__version__ = "5.6.7" __support__ = "Discord: https://discord.gg/nQqJe8qvP8" diff --git a/rustplus/api/remote/expo_bundle_handler.py b/rustplus/api/remote/expo_bundle_handler.py index 3d35d5a..9de2e66 100644 --- a/rustplus/api/remote/expo_bundle_handler.py +++ b/rustplus/api/remote/expo_bundle_handler.py @@ -1,48 +1,22 @@ import requests import logging -import json -from datetime import datetime class MagicValueGrabber: @staticmethod def get_magic_value() -> int: - try: - data = requests.get( - "https://exp.host/@facepunch/RustCompanion", - headers={ - "Exponent-SDK-Version": "40.0.0", # These are the two lines that determine the version of data that - "Exponent-Version": "0.0.29", # you receive as far as I can tell from my limited debugging. As of - # now (8th April 2022), this is the latest - "Exponent-Platform": "android", - "Accept": "application/expo+json,application/json", - "Expo-Release-Channel": "default", - "Expo-Api-Version": "1", - "Expo-Client-Environment": "STANDALONE", - "Exponent-Accept-Signature": "true", - "Expo-JSON-Error": "true", - "Host": "exp.host", - "User-Agent": "okhttp/3.12.1", - }, - ) - halves = ( - str(json.loads(data.json()["manifestString"])["publishedTime"]) - .replace("Z", "") - .split("T") - ) + data = requests.get( + "https://companion-rust.facepunch.com/api/version" + ) - year, month, day = halves[0].split("-") - hour, minute, second = halves[1].split(":") + if data.status_code == 200: + data = data.json() + time = data.get("minPublishedTime", None) + if time is not None: + return time + 1 - dt = datetime(int(year), int(month), int(day), int(hour), int(minute), 0) - - return int( - ((dt - datetime.utcfromtimestamp(0)).total_seconds() * 1000.0) - + float(second) * 1000 - ) - except Exception: - logging.getLogger("rustplus.py").warning( - "[Rustplus.py] Failed to get magic value from RustPlus Server" - ) - return 1641359159846 + logging.getLogger("rustplus.py").warning( + "[Rustplus.py] Failed to get magic value from RustPlus Server" + ) + return 9999999999999