Skip to content

Commit

Permalink
Try to implement some anty-captcha, #22
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed Nov 26, 2015
1 parent 173148c commit 84db370
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
10 changes: 8 additions & 2 deletions ArchiSteamFarm/Bot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,12 @@ private async void OnLoggedOn(SteamUser.LoggedOnCallback callback) {
case EResult.AccountLoginDeniedNeedTwoFactor:
TwoFactorAuth = Program.GetUserInput(SteamLogin, Program.EUserInputType.TwoFactorAuthentication);
break;
case EResult.InvalidPassword:
Logging.LogGenericWarning(BotName, "Unable to login to Steam: " + result + ", will retry after a longer while");
await Stop().ConfigureAwait(false);
await Utilities.SleepAsync(1000 * 20 * Utilities.RandomDice()).ConfigureAwait(false); // TODO: Find out the required delay
await Start().ConfigureAwait(false);
break;
case EResult.OK:
Logging.LogGenericInfo(BotName, "Successfully logged on!");

Expand Down Expand Up @@ -551,12 +557,12 @@ private async void OnLoggedOn(SteamUser.LoggedOnCallback callback) {
break;
case EResult.Timeout:
case EResult.TryAnotherCM:
Logging.LogGenericWarning(BotName, "Unable to login to Steam: " + callback.Result + " / " + callback.ExtendedResult + ", retrying...");
Logging.LogGenericWarning(BotName, "Unable to login to Steam: " + result + ", retrying...");
await Stop().ConfigureAwait(false);
await Start().ConfigureAwait(false);
break;
default:
Logging.LogGenericWarning(BotName, "Unable to login to Steam: " + callback.Result + " / " + callback.ExtendedResult);
Logging.LogGenericWarning(BotName, "Unable to login to Steam: " + result);
await Shutdown().ConfigureAwait(false);
break;
}
Expand Down
14 changes: 8 additions & 6 deletions ArchiSteamFarm/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,23 @@ limitations under the License.
*/

using HtmlAgilityPack;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ArchiSteamFarm {
internal static class Utilities {
private static readonly Random Random = new Random();

internal static int RandomNumber(int min, int max) {
return Random.Next(min, max + 1);
}

internal static byte RandomDice() {
return (byte) RandomNumber(1, 6);
}

internal static async Task SleepAsync(int miliseconds) {
await Task.Delay(miliseconds).ConfigureAwait(false);
}
Expand Down

0 comments on commit 84db370

Please sign in to comment.