Skip to content

Commit

Permalink
Fix Facepunch changing something with EXPO, use their endpoint now
Browse files Browse the repository at this point in the history
  • Loading branch information
olijeffers0n committed Jun 27, 2023
1 parent d843075 commit 55ea0af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 39 deletions.
2 changes: 1 addition & 1 deletion rustplus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@

__name__ = "rustplus"
__author__ = "olijeffers0n"
__version__ = "5.6.6"
__version__ = "5.6.7"
__support__ = "Discord: https://discord.gg/nQqJe8qvP8"
50 changes: 12 additions & 38 deletions rustplus/api/remote/expo_bundle_handler.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 55ea0af

Please sign in to comment.