예제 #1
0
파일: general.py 프로젝트: mgracer48/RbxAPI
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()
예제 #2
0
파일: general.py 프로젝트: mgracer48/RbxAPI
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