Add support for longer cd-keys

This commit is contained in:
JustArchi 2015-11-25 16:49:01 +01:00
parent 0fd0528fd0
commit 173148ce25
2 changed files with 20 additions and 2 deletions

View file

@ -34,7 +34,7 @@ using System.Threading.Tasks;
namespace ArchiSteamFarm {
internal class ArchiWebHandler {
private const uint Timeout = 1000 * WebBrowser.HttpTimeout; // In miliseconds
private const int Timeout = 1000 * WebBrowser.HttpTimeout; // In miliseconds
private readonly Bot Bot;
private readonly string ApiKey;

View file

@ -67,6 +67,24 @@ namespace ArchiSteamFarm {
internal HashSet<uint> Blacklist { get; private set; } = new HashSet<uint> { 303700, 335590, 368020 };
internal bool Statistics { get; private set; } = true;
private static bool IsValidCdKey(string key) {
if (string.IsNullOrEmpty(key)) {
return false;
}
if (key.Length != 17 && key.Length != 29) {
return false;
}
for (byte i = 5; i < key.Length; i += 6) {
if (key[i] != '-') {
return false;
}
}
return true;
}
internal static int GetRunningBotsCount() {
return Bots.Count;
}
@ -429,7 +447,7 @@ namespace ArchiSteamFarm {
return;
}
if (message.Length == 17 && message[5] == '-' && message[11] == '-') {
if (IsValidCdKey(message)) {
ArchiHandler.RedeemKey(message);
return;
}