import RecNet as rn import dto import time import random import jwt import webbrowser import sys inventionId = None for arg in sys.argv: if arg.startswith("inventionId="): inventionId = arg.split("inventionId=")[1] if inventionId is None: print("Missing required 'inventionId' argument.") sys.exit(1) #Check out this invention in RecRoom: https://rec.net/d/store/invention/7659560881412086938 loggedIn = False testauth = rn.genAuthCode() print(testauth.verificationUriComplete) webbrowser.open(testauth.verificationUriComplete) while not loggedIn: test2 = rn.loginWithDeviceCode(testauth.deviceCode) if test2.accessToken is not None: token = jwt.decode(test2.accessToken, options={"verify_signature": False}) print(test2.accessToken) role = token.get("role") betastudio = False if isinstance(role, list): if "betastudio" in role: betastudio = True elif role == "betastudio": betastudio = True if not betastudio: print("Your account does not have access to Beta Studio.") sys.exit(1) rn.auth = test2.accessToken loggedIn = True break if test2.error != "authorization_pending": print(f"Error: {test2.error}") break time.sleep(testauth.interval) #print(test2.accessToken) myAccount = rn.sendRequest(rn.HTTPMethod.GET, rn.Service.Accounts, "account/me") myAccount = dto.Account(myAccount.json()) inventions = rn.sendRequest(rn.HTTPMethod.GET, rn.Service.API, f"api/inventions/v2/batch?id={inventionId}") if len(inventions.json()) == 0: sys.exit(3) invention = dto.Invention(inventions.json()[0]) newInventionPayoad = { "creatorAccountRole": 30, "instantiationCost": invention.CurrentVersion.InstantiationCost, "lightsCost": invention.CurrentVersion.LightsCost, "chipsCost": invention.CurrentVersion.ChipsCost, "cloudVariablesCost": invention.CurrentVersion.CloudVariablesCost, "ugcVersion": invention.UgcVersion, "hasBetaContent": invention.CurrentVersion.HasBetaContent, "name": invention.Name, "imageName": invention.ImageName, "inventionDataFilename":invention.CurrentVersion.BlobName } newInvention = rn.sendRequest(rn.HTTPMethod.POST, rn.Service.API, f"api/inventions/v9/save", data=newInventionPayoad) print(newInvention) print(newInvention.text) #7416601836735484223 -00zay