Skip to content

Commit 84db370

Browse files
committed
Try to implement some anty-captcha, #22
1 parent 173148c commit 84db370

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

ArchiSteamFarm/Bot.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,12 @@ private async void OnLoggedOn(SteamUser.LoggedOnCallback callback) {
524524
case EResult.AccountLoginDeniedNeedTwoFactor:
525525
TwoFactorAuth = Program.GetUserInput(SteamLogin, Program.EUserInputType.TwoFactorAuthentication);
526526
break;
527+
case EResult.InvalidPassword:
528+
Logging.LogGenericWarning(BotName, "Unable to login to Steam: " + result + ", will retry after a longer while");
529+
await Stop().ConfigureAwait(false);
530+
await Utilities.SleepAsync(1000 * 20 * Utilities.RandomDice()).ConfigureAwait(false); // TODO: Find out the required delay
531+
await Start().ConfigureAwait(false);
532+
break;
527533
case EResult.OK:
528534
Logging.LogGenericInfo(BotName, "Successfully logged on!");
529535

@@ -551,12 +557,12 @@ private async void OnLoggedOn(SteamUser.LoggedOnCallback callback) {
551557
break;
552558
case EResult.Timeout:
553559
case EResult.TryAnotherCM:
554-
Logging.LogGenericWarning(BotName, "Unable to login to Steam: " + callback.Result + " / " + callback.ExtendedResult + ", retrying...");
560+
Logging.LogGenericWarning(BotName, "Unable to login to Steam: " + result + ", retrying...");
555561
await Stop().ConfigureAwait(false);
556562
await Start().ConfigureAwait(false);
557563
break;
558564
default:
559-
Logging.LogGenericWarning(BotName, "Unable to login to Steam: " + callback.Result + " / " + callback.ExtendedResult);
565+
Logging.LogGenericWarning(BotName, "Unable to login to Steam: " + result);
560566
await Shutdown().ConfigureAwait(false);
561567
break;
562568
}

ArchiSteamFarm/Utilities.cs

+8-6
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,23 @@ limitations under the License.
2222
2323
*/
2424

25-
using HtmlAgilityPack;
26-
using Newtonsoft.Json.Linq;
2725
using System;
28-
using System.Collections.Generic;
2926
using System.Globalization;
30-
using System.Net;
31-
using System.Net.Http;
32-
using System.Text;
3327
using System.Text.RegularExpressions;
3428
using System.Threading.Tasks;
3529

3630
namespace ArchiSteamFarm {
3731
internal static class Utilities {
3832
private static readonly Random Random = new Random();
3933

34+
internal static int RandomNumber(int min, int max) {
35+
return Random.Next(min, max + 1);
36+
}
37+
38+
internal static byte RandomDice() {
39+
return (byte) RandomNumber(1, 6);
40+
}
41+
4042
internal static async Task SleepAsync(int miliseconds) {
4143
await Task.Delay(miliseconds).ConfigureAwait(false);
4244
}

0 commit comments

Comments
 (0)