RocketBot icon indicating copy to clipboard operation
RocketBot copied to clipboard

Does not restart please Fix

Open Trackhe opened this issue 10 years ago • 11 comments

does not restart

Trackhe avatar Jul 23 '16 13:07 Trackhe

Actually it does because it runs the Execute() method again once that error is thrown.

catch (NullReferenceException) { ColoredConsoleWrite(ConsoleColor.White, "Null Refference - Restarting"); Execute(); }

It just keeps throwing the error - I would say either restart or give it 5 more minutes?

Versified avatar Jul 23 '16 13:07 Versified

I restart every time. the next time I give him 5 minutes.

can you make a automatic restart?

Trackhe avatar Jul 23 '16 13:07 Trackhe

Well, I could, yes.

But I don't believe it would be effective.

Versified avatar Jul 23 '16 13:07 Versified

I use google and i starting with strg and f5 and if there is this error and I was asleep the ( rest arte ) goes immediately passed

Trackhe avatar Jul 23 '16 13:07 Trackhe

modify client.cs, line 85 to use refresh token instead of access token. because google access token does expire while refresh token doesn't

evoamac avatar Jul 23 '16 13:07 evoamac

@evoamac can you show code?

zon999 avatar Jul 23 '16 13:07 zon999

       public async Task DoGoogleLogin()
        {
            _authType = AuthType.Google;
            GoogleLogin.TokenResponseModel tokenResponse = null;

            if (_settings.GoogleRefreshToken == string.Empty && AccessToken == string.Empty)
            {
                var deviceCode = await GoogleLogin.GetDeviceCode();
                tokenResponse = await GoogleLogin.GetAccessToken(deviceCode);
                _accessToken = tokenResponse.id_token;
                Console.WriteLine($"Put RefreshToken in settings for direct login: {tokenResponse.refresh_token}");
                _settings.GoogleRefreshToken = tokenResponse.refresh_token;
                AccessToken = tokenResponse.refresh_token;
            }
            else
            {
                if (_settings.GoogleRefreshToken != null)
                    tokenResponse = await GoogleLogin.GetAccessToken(_settings.GoogleRefreshToken);
                else
                    tokenResponse = await GoogleLogin.GetAccessToken(AccessToken);
                _accessToken = tokenResponse.id_token;
            }
        }

This is what I have and it's working well so far. I had the error once though, few hours ago.

v7nce avatar Jul 23 '16 13:07 v7nce

in client.cs change Console.WriteLine($"Put RefreshToken in settings for direct login: {tokenResponse.accessToken}"); To Console.WriteLine($"Put RefreshToken in settings for direct login: {tokenResponse.refresh_token}");

evoamac avatar Jul 23 '16 14:07 evoamac

and you will get a short token in the console while first login, put that token in your app.config.

evoamac avatar Jul 23 '16 14:07 evoamac

I'd recommend you to just update your bot. The newest version does all that stuff automatically.

v7nce avatar Jul 23 '16 14:07 v7nce

I updated code Console.WriteLine($"Put RefreshToken in settings for direct login: {tokenResponse.refresh_token}"); But still get same error? Huh

zon999 avatar Jul 23 '16 14:07 zon999