def Login(username, pwd): """ Login into the account :param pwd: Password used to login :type pwd: str :param username: Username used to log in :type username: str """ username = str(username) if not username: raise errors.NoUsernameError() with open(ReturnConfigPath(username + '.acc'), 'wb') as f: data = {'username': username, 'password': pwd} Session.post(LOGIN_URL, data=data) # login Session.get(CHECK_URL) if '.ROBLOSECURITY' in Session.cookies: # pickle.dump(Session.cookies, f) pickle.dump(data, f) # Save the username and password now. This way we can automatically login and # support running the bot 24/7 nonstop. Currently the cookie can expire and crash it. print('Save Successful') User._SetLoggedIn(username) return True else: f.close() os.remove(f.name) raise errors.AccountsError()
def LoadAccounts(username): """ Load the specififed account :param username: The account to load :type username: str :return: True if success :rtype: bool """ username = str(username) with open(ReturnConfigPath(username + '.acc'), 'rb') as file: try: # cookies = pickle.load(file) data = pickle.load(file) except EOFError: raise errors.StorageError() # Session.cookies = cookies Session.post(LOGIN_URL, data=data) # For auto login if Session.get(CHECK_URL).url != CHECK_URL: raise errors.AccountsError() User._SetLoggedIn(username) return True