public async Task <EResult> EasyIdling() { var res = await _loginHandler.Login(SteamServerList.GetServerRecord()); if (res == EResult.OK) { _steamAccount.LastRun = DateTime.UtcNow; _steamAccount.IdleNow = true; _steamAccount.Save(); var appId = _steamAccount.AppIds; if (appId.Any()) { PlayGames(appId); await CheckTimeItemsList(_steamAccount.DropConfig); Thread.Sleep(1000 * 60 * 30); PlayGames(appId); Thread.Sleep(1000 * 60 * 30); await CheckTimeItemsList(_steamAccount.DropConfig); StopGame(); } _steamAccount.IdleNow = false; _steamAccount.Save(); } return(res); }
public void LogOf() { Thread.Sleep(5000); _work = false; _client.Disconnect(); SteamServerList.ReleasServerRecord(_loginHandler.ServerRecord); }
public async Task <T> Execute <T>(Func <SteamMachine, T> func) { var res = await _loginHandler.Login(SteamServerList.GetServerRecord()); if (res == EResult.OK) { var ret = func(this); LogOf(); return(ret); } LogOf(); return(default(T)); }
void OnLoggedOn(SteamUser.LoggedOnCallback callback) { Console.WriteLine(callback.Result); bool isSteamGuard = callback.Result == EResult.AccountLogonDenied; bool is2Fa = callback.Result == EResult.AccountLoginDeniedNeedTwoFactor; tryLoginCount++; if (tryLoginCount > 5) { _loginTcs?.SetResult(callback.Result); } if (isSteamGuard || is2Fa) { // Console.WriteLine("This account is SteamGuard protected!"); if (is2Fa) { _twoFactorAuth = _steamAccount.MobileAuth.GenerateSteamGuardCode(); if (_twoFactorAuth == null) { Console.WriteLine($"{_steamAccount.Name}: MobileSteamGuard настроен не верно"); } } else { throw new NotImplementedException("Not inplemented auth code. Only mobile auth"); } return; } if (callback.Result != EResult.OK) { if (callback.Result == EResult.InvalidPassword) { _steamAccount.LoginKey = null; _steamAccount.Save(); } else if (callback.Result == EResult.NoConnection) { SteamServerList.SetBadServer(_serverRecord); _serverRecord = SteamServerList.GetServerRecord(); } Console.WriteLine("Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult); return; } _steamAccount.SteamId = _client.SteamID; Console.WriteLine("Successfully logged on!"); _loginTcs?.SetResult(callback.Result); }