ArchiSteamFarm/ConfigGenerator/BotConfig.cs

213 lines
6.5 KiB
C#
Raw Normal View History

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;
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;
using Newtonsoft.Json;
2016-03-20 05:41:12 +00:00
namespace ConfigGenerator {
[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 {
[LocalizedCategory("Advanced")]
[JsonProperty(Required = Required.DisallowNull)]
public byte AcceptConfirmationsPeriod { get; set; } = 0;
2016-03-20 05:41:12 +00:00
[JsonProperty(Required = Required.DisallowNull)]
public bool AcceptGifts { get; set; } = false;
2016-03-20 05:41:12 +00:00
[LocalizedCategory("Performance")]
[JsonProperty(Required = Required.DisallowNull)]
public bool CardDropsRestricted { get; set; } = true;
2016-03-20 05:41:12 +00:00
[JsonProperty]
public string CustomGamePlayedWhileFarming { get; set; } = null;
2016-03-20 05:41:12 +00:00
[JsonProperty]
public string CustomGamePlayedWhileIdle { get; set; } = null;
2016-03-20 05:41:12 +00:00
[JsonProperty(Required = Required.DisallowNull)]
public bool DismissInventoryNotifications { get; set; } = true;
2016-03-20 05:41:12 +00:00
[LocalizedCategory("Core")]
2016-03-20 05:41:12 +00:00
[JsonProperty(Required = Required.DisallowNull)]
public bool Enabled { get; set; } = false;
2016-03-20 05:41:12 +00:00
[JsonProperty(Required = Required.DisallowNull)]
public EFarmingOrder FarmingOrder { get; set; } = EFarmingOrder.Unordered;
2016-03-20 05:41:12 +00:00
[JsonProperty(Required = Required.DisallowNull)]
public bool FarmOffline { get; set; } = false;
2016-03-20 05:41:12 +00:00
[JsonProperty(Required = Required.DisallowNull)]
public List<uint> GamesPlayedWhileIdle { get; set; } = new List<uint>();
2016-03-20 05:41:12 +00:00
[LocalizedCategory("Advanced")]
2016-03-20 05:41:12 +00:00
[JsonProperty(Required = Required.DisallowNull)]
public bool HandleOfflineMessages { get; set; } = false;
[LocalizedCategory("Advanced")]
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
[LocalizedCategory("Advanced")]
[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
[LocalizedCategory("Access")]
2016-03-20 05:41:12 +00:00
[JsonProperty(Required = Required.DisallowNull)]
public ECryptoMethod PasswordFormat { get; set; } = ECryptoMethod.PlainText;
[LocalizedCategory("Advanced")]
[JsonProperty(Required = Required.DisallowNull)]
public bool Paused { get; set; } = false;
2016-03-20 05:41:12 +00:00
[LocalizedCategory("Advanced")]
[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)]
public bool SendOnFarmingFinished { get; set; } = false;
2016-03-20 05:41:12 +00:00
[JsonProperty(Required = Required.DisallowNull)]
public byte SendTradePeriod { get; set; } = 0;
2016-03-20 05:41:12 +00:00
[JsonProperty(Required = Required.DisallowNull)]
public bool ShutdownOnFarmingFinished { get; set; } = false;
2016-03-20 05:41:12 +00:00
[LocalizedCategory("Core")]
[JsonProperty]
public string SteamLogin { get; set; } = null;
2016-03-20 05:41:12 +00:00
[LocalizedCategory("Access")]
[JsonProperty(Required = Required.DisallowNull)]
public ulong SteamMasterClanID { get; set; } = 0;
[LocalizedCategory("Access")]
2016-03-20 05:41:12 +00:00
[JsonProperty(Required = Required.DisallowNull)]
public ulong SteamMasterID { get; set; } = 0;
2016-03-20 05:41:12 +00:00
[LocalizedCategory("Access")]
[JsonProperty]
public string SteamParentalPIN { get; set; } = "0";
[LocalizedCategory("Core")]
2016-03-20 05:41:12 +00:00
[JsonProperty]
[PasswordPropertyText(true)]
public string SteamPassword { get; set; } = null;
[LocalizedCategory("Access")]
[JsonProperty]
public string SteamTradeToken { get; set; } = null;
2016-03-20 05:41:12 +00:00
[LocalizedCategory("Advanced")]
[Editor(typeof(FlagEnumUiEditor), typeof(UITypeEditor))]
2016-03-20 05:41:12 +00:00
[JsonProperty(Required = Required.DisallowNull)]
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;
}
internal enum ECryptoMethod : byte {
PlainText,
AES,
ProtectedDataForCurrentUser
}
2016-03-20 05:41:12 +00:00
internal enum EFarmingOrder : byte {
Unordered,
AppIDsAscending,
AppIDsDescending,
CardDropsAscending,
CardDropsDescending,
HoursAscending,
HoursDescending,
NamesAscending,
NamesDescending
}
2016-04-12 17:12:45 +00:00
[Flags]
internal enum ERedeemingPreferences : byte {
None = 0,
Forwarding = 1,
Distributing = 2
}
[Flags]
internal enum ETradingPreferences : byte {
None = 0,
AcceptDonations = 1,
SteamTradeMatcher = 2,
MatchEverything = 4
2016-03-20 05:41:12 +00:00
}
}
}