def ExcHandler(exception_type, exception, errorTraceback, debug_hook=sys.excepthook): """ Handle proper exceptions being displayed. :param exception_type: Type :type exception_type: Exception :param exception: Exception :type exception: :param errorTraceback: The traceback of the exception. :type errorTraceback: traceback :param debug_hook: Backup, is the orginial function :type debug_hook: sys.excepthook """ if False: debug_hook(exception_type, exception, errorTraceback) else: from RbxAPI import ReturnDesktopPath Text = "Error: {0}: {1}\nTraceback(Send this to Iaz3 WITH Debug.log on your desktop):\n{2}".format( exception_type.__name__, exception, TracebackHandler(errorTraceback)) DebugLog.debug("\n\n{0}\n\n".format(Text)) try: from shutil import copyfile as copy copy("Debug.log", ReturnDesktopPath()) except OSError: print("\nError: Couldent copy Debug.log to desktop.\n") print("Debug.log will be at: {0}".format(os.path.abspath("Debug.log"))) pass print(Text)
def GetCash(): """ Check how much cash the user has using ROBLOX's API. Requires logged in. :return int: Robux, tickets. :rtype: int, int """ while True: r = Session.get(CURRENCY_URL) try: val = r.json() except JSONDecodeError: DebugLog.debug(r.text) continue break return int(val['robux']), int(val['tickets'])
def Calculate(): """ Where the trade/profit "calculation" happens """ lastBux, lastTix = GetCash() print("The bot has started. Do not fear if nothing is shown on screen/it doesnt change for a long time. It is " "working\n") while True: waitTime = 0 while IsTradeActive(): waitTime = 1 # waitTime += 1 # print("Progress {:2.1%}".format(waitTime / 10), end="\r") print('Waiting for trade to go through.', end='\r') time.sleep(10) if waitTime == 1: print("\nDone Waiting For Trade to go through.\n") bux, tix = GetCash() # Money buxRate, tixRate = GetRate() DebugLog.debug("\nRobux: {0}\nTickets: {1}\n".format(bux, tix)) DebugLog.debug("Robux Rate: {0}\nTickets Rate: {1}\n".format(buxRate, tixRate)) # spread = GetSpread() if (buxRate == 0.0000) or (tixRate == 0.0000) or (abs(buxRate - tixRate) >= 10): DebugLog.info("Bad Rates") continue if bux: # Bux to Tix tixWant = int(math.floor(bux * tixRate)) if tixWant > lastTix: print("Getting {0} Tix for {1} Bux\n".format(tixWant, bux)) DebugLog.debug("\n\nGetting {0} Tix for {1} Bux\n\n".format(tixWant, bux)) lastBux = bux SubmitTrade(bux, tixWant, "Robux") elif tix: # Tix to Bux buxWant = int(math.floor(tix / buxRate)) tixCost = int(math.ceil(buxWant * buxRate)) buxProfit = buxWant - lastBux tixProfit = tix - tixCost DebugLog.debug("BuxWant: {0}\nTixCost: {1}\nBuxProfit: {2}\nTixProfit:" " {3}\nLastBux: {4}\nLastTix: {5}".format(buxWant, tixCost, buxProfit, tixProfit, lastBux, lastTix)) if buxProfit > 0 and tixProfit > 0 or buxProfit > 0 and abs(tixProfit) <= 5: print("Getting {0} Bux for {1} Tix with " "a potential profit of:\n{2} Robux\n{3} Tickets\n".format(buxWant, tixCost, buxProfit, tixProfit)) DebugLog.debug("\n\nGetting {0} Bux for {1} Tix with " "a potential profit of:\n{2} Robux\n{3} Tickets\n\n".format(buxWant, tixCost, buxProfit, tixProfit)) lastTix = tix + tixProfit SubmitTrade(tixCost, buxWant, 'Tickets') time.sleep(2)