2016-03-20 05:41:12 +00:00
|
|
|
|
/*
|
|
|
|
|
_ _ _ ____ _ _____
|
|
|
|
|
/ \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
|
|
|
|
|
/ _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
|
|
|
|
|
/ ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
|
|
|
|
|
/_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
|
|
|
|
|
|
2017-01-02 19:05:21 +00:00
|
|
|
|
Copyright 2015-2017 Łukasz "JustArchi" Domeradzki
|
2016-03-20 05:41:12 +00:00
|
|
|
|
Contact: JustArchi@JustArchi.net
|
|
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2016-04-26 12:23:44 +00:00
|
|
|
|
using System.ComponentModel;
|
2016-05-13 04:32:42 +00:00
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2016-11-24 06:32:16 +00:00
|
|
|
|
using System.Drawing.Design;
|
2016-03-20 05:41:12 +00:00
|
|
|
|
using System.IO;
|
2016-12-25 04:52:17 +00:00
|
|
|
|
using ConfigGenerator.JSON;
|
2016-11-24 06:32:16 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
|
|
|
|
namespace ConfigGenerator {
|
2016-06-08 23:15:48 +00:00
|
|
|
|
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Global")]
|
|
|
|
|
[SuppressMessage("ReSharper", "CollectionNeverQueried.Global")]
|
|
|
|
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
|
|
|
|
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
2016-03-20 05:41:12 +00:00
|
|
|
|
internal sealed class BotConfig : ASFConfig {
|
2016-11-24 06:32:16 +00:00
|
|
|
|
[Category("\tAdvanced")]
|
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
|
|
|
|
public byte AcceptConfirmationsPeriod { get; set; } = 0;
|
2016-10-21 18:32:22 +00:00
|
|
|
|
|
2016-03-20 05:41:12 +00:00
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public bool AcceptGifts { get; set; } = false;
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
2016-11-24 06:32:16 +00:00
|
|
|
|
[Category("\tPerformance")]
|
2016-10-01 19:09:24 +00:00
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public bool CardDropsRestricted { get; set; } = true;
|
2016-10-01 19:09:24 +00:00
|
|
|
|
|
2016-03-20 05:41:12 +00:00
|
|
|
|
[JsonProperty]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public string CustomGamePlayedWhileFarming { get; set; } = null;
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
2016-06-08 23:15:48 +00:00
|
|
|
|
[JsonProperty]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public string CustomGamePlayedWhileIdle { get; set; } = null;
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
2016-06-28 02:32:48 +00:00
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public bool DismissInventoryNotifications { get; set; } = true;
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
2016-11-24 06:32:16 +00:00
|
|
|
|
[Category("\t\tCore")]
|
2016-03-20 05:41:12 +00:00
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public bool Enabled { get; set; } = false;
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public EFarmingOrder FarmingOrder { get; set; } = EFarmingOrder.Unordered;
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public bool FarmOffline { get; set; } = false;
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public List<uint> GamesPlayedWhileIdle { get; set; } = new List<uint>();
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
2016-08-10 16:03:14 +00:00
|
|
|
|
[Category("\tAdvanced")]
|
2016-03-20 05:41:12 +00:00
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
|
|
|
|
public bool HandleOfflineMessages { get; set; } = false;
|
|
|
|
|
|
2016-08-10 16:03:14 +00:00
|
|
|
|
[Category("\tAdvanced")]
|
2016-06-04 20:02:38 +00:00
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
|
|
|
|
public bool IsBotAccount { get; set; } = false;
|
2016-03-27 21:27:02 +00:00
|
|
|
|
|
2016-12-30 12:10:09 +00:00
|
|
|
|
[Category("\tAdvanced")]
|
2016-12-30 12:01:02 +00:00
|
|
|
|
[JsonProperty(ObjectCreationHandling = ObjectCreationHandling.Replace, Required = Required.DisallowNull)]
|
2017-01-05 20:08:13 +00:00
|
|
|
|
public List<Steam.Item.EType> LootableTypes { get; set; } = new List<Steam.Item.EType> {
|
|
|
|
|
Steam.Item.EType.BoosterPack,
|
|
|
|
|
Steam.Item.EType.FoilTradingCard,
|
|
|
|
|
Steam.Item.EType.TradingCard
|
|
|
|
|
};
|
2016-12-25 04:52:17 +00:00
|
|
|
|
|
2016-11-24 06:32:16 +00:00
|
|
|
|
[Category("\tAccess")]
|
2016-03-20 05:41:12 +00:00
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public ECryptoMethod PasswordFormat { get; set; } = ECryptoMethod.PlainText;
|
|
|
|
|
|
|
|
|
|
[Category("\tAdvanced")]
|
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
|
|
|
|
public bool Paused { get; set; } = false;
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
2016-12-25 05:29:13 +00:00
|
|
|
|
[Category("\tAdvanced")]
|
|
|
|
|
[Editor(typeof(FlagEnumUiEditor), typeof(UITypeEditor))]
|
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
|
|
|
|
public ERedeemingPreferences RedeemingPreferences { get; set; } = ERedeemingPreferences.None;
|
|
|
|
|
|
2016-03-20 05:41:12 +00:00
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public bool SendOnFarmingFinished { get; set; } = false;
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public byte SendTradePeriod { get; set; } = 0;
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public bool ShutdownOnFarmingFinished { get; set; } = false;
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
2016-08-10 16:03:14 +00:00
|
|
|
|
[Category("\tAccess")]
|
2016-03-20 05:41:12 +00:00
|
|
|
|
[JsonProperty]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public string SteamApiKey { get; set; } = null;
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
2016-11-24 06:32:16 +00:00
|
|
|
|
[Category("\t\tCore")]
|
|
|
|
|
[JsonProperty]
|
|
|
|
|
public string SteamLogin { get; set; } = null;
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
2016-11-24 06:32:16 +00:00
|
|
|
|
[Category("\tAccess")]
|
2016-10-21 18:32:22 +00:00
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public ulong SteamMasterClanID { get; set; } = 0;
|
2016-10-21 18:32:22 +00:00
|
|
|
|
|
2016-11-24 06:32:16 +00:00
|
|
|
|
[Category("\tAccess")]
|
2016-03-20 05:41:12 +00:00
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public ulong SteamMasterID { get; set; } = 0;
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
2016-11-24 06:32:16 +00:00
|
|
|
|
[Category("\tAccess")]
|
2016-07-12 02:40:56 +00:00
|
|
|
|
[JsonProperty]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public string SteamParentalPIN { get; set; } = "0";
|
2016-07-12 02:40:56 +00:00
|
|
|
|
|
2016-11-24 06:32:16 +00:00
|
|
|
|
[Category("\t\tCore")]
|
2016-03-20 05:41:12 +00:00
|
|
|
|
[JsonProperty]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
[PasswordPropertyText(true)]
|
|
|
|
|
public string SteamPassword { get; set; } = null;
|
|
|
|
|
|
|
|
|
|
[Category("\tAccess")]
|
|
|
|
|
[JsonProperty]
|
|
|
|
|
public string SteamTradeToken { get; set; } = null;
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
2016-11-24 06:32:16 +00:00
|
|
|
|
[Category("\tAdvanced")]
|
|
|
|
|
[Editor(typeof(FlagEnumUiEditor), typeof(UITypeEditor))]
|
2016-03-20 05:41:12 +00:00
|
|
|
|
[JsonProperty(Required = Required.DisallowNull)]
|
2016-11-24 06:32:16 +00:00
|
|
|
|
public ETradingPreferences TradingPreferences { get; set; } = ETradingPreferences.AcceptDonations;
|
|
|
|
|
|
|
|
|
|
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
|
|
|
|
private BotConfig() { }
|
|
|
|
|
|
|
|
|
|
private BotConfig(string filePath) : base(filePath) {
|
|
|
|
|
if (string.IsNullOrEmpty(filePath)) {
|
|
|
|
|
throw new ArgumentNullException(nameof(filePath));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Save();
|
|
|
|
|
}
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
|
|
|
|
internal static BotConfig Load(string filePath) {
|
|
|
|
|
if (string.IsNullOrEmpty(filePath)) {
|
2016-05-29 23:57:06 +00:00
|
|
|
|
Logging.LogNullError(nameof(filePath));
|
2016-03-20 05:41:12 +00:00
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!File.Exists(filePath)) {
|
|
|
|
|
return new BotConfig(filePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BotConfig botConfig;
|
2016-05-29 23:57:06 +00:00
|
|
|
|
|
2016-03-20 05:41:12 +00:00
|
|
|
|
try {
|
|
|
|
|
botConfig = JsonConvert.DeserializeObject<BotConfig>(File.ReadAllText(filePath));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
Logging.LogGenericException(e);
|
|
|
|
|
return new BotConfig(filePath);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-28 11:11:02 +00:00
|
|
|
|
if (botConfig == null) {
|
|
|
|
|
return new BotConfig(filePath);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-20 05:41:12 +00:00
|
|
|
|
botConfig.FilePath = filePath;
|
|
|
|
|
|
|
|
|
|
return botConfig;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-24 06:32:16 +00:00
|
|
|
|
internal enum ECryptoMethod : byte {
|
|
|
|
|
PlainText,
|
|
|
|
|
AES,
|
|
|
|
|
ProtectedDataForCurrentUser
|
|
|
|
|
}
|
2016-03-20 05:41:12 +00:00
|
|
|
|
|
2016-11-24 06:32:16 +00:00
|
|
|
|
internal enum EFarmingOrder : byte {
|
|
|
|
|
Unordered,
|
|
|
|
|
AppIDsAscending,
|
|
|
|
|
AppIDsDescending,
|
|
|
|
|
CardDropsAscending,
|
|
|
|
|
CardDropsDescending,
|
|
|
|
|
HoursAscending,
|
|
|
|
|
HoursDescending,
|
|
|
|
|
NamesAscending,
|
|
|
|
|
NamesDescending
|
|
|
|
|
}
|
2016-04-12 17:12:45 +00:00
|
|
|
|
|
2016-12-25 05:29:13 +00:00
|
|
|
|
[Flags]
|
|
|
|
|
internal enum ERedeemingPreferences : byte {
|
|
|
|
|
None = 0,
|
|
|
|
|
Forwarding = 1,
|
|
|
|
|
Distributing = 2
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-24 06:32:16 +00:00
|
|
|
|
[Flags]
|
|
|
|
|
internal enum ETradingPreferences : byte {
|
|
|
|
|
None = 0,
|
|
|
|
|
AcceptDonations = 1,
|
|
|
|
|
SteamTradeMatcher = 2,
|
|
|
|
|
MatchEverything = 4
|
2016-03-20 05:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-24 06:32:16 +00:00
|
|
|
|
}
|