mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-10 13:44:22 +00:00
General code review
This commit is contained in:
@@ -346,12 +346,7 @@ namespace ArchiSteamFarm {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (botName) {
|
||||
case SharedInfo.ASF:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
return !botName.Equals(SharedInfo.ASF, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private static async void OnChanged(object sender, FileSystemEventArgs e) {
|
||||
@@ -426,7 +421,7 @@ namespace ArchiSteamFarm {
|
||||
return;
|
||||
}
|
||||
|
||||
if (botName.Equals(SharedInfo.ASF)) {
|
||||
if (botName.Equals(SharedInfo.ASF, StringComparison.OrdinalIgnoreCase)) {
|
||||
ArchiLogger.LogGenericInfo(Strings.GlobalConfigChanged);
|
||||
await RestartOrExit().ConfigureAwait(false);
|
||||
|
||||
@@ -520,7 +515,7 @@ namespace ArchiSteamFarm {
|
||||
return;
|
||||
}
|
||||
|
||||
if (botName.Equals(SharedInfo.ASF)) {
|
||||
if (botName.Equals(SharedInfo.ASF, StringComparison.OrdinalIgnoreCase)) {
|
||||
if (File.Exists(fullPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -138,9 +138,11 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = SharedInfo.UlongCompatibilityStringPrefix + nameof(SteamID))]
|
||||
[NotNull]
|
||||
private string SSteamID => SteamID.ToString();
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
[JsonProperty]
|
||||
public EAccountFlags AccountFlags { get; private set; }
|
||||
@@ -168,8 +170,10 @@ namespace ArchiSteamFarm {
|
||||
|
||||
private string AuthCode;
|
||||
|
||||
#pragma warning disable IDE0052
|
||||
[JsonProperty]
|
||||
private string AvatarHash;
|
||||
#pragma warning restore IDE0052
|
||||
|
||||
private Timer ConnectionFailureTimer;
|
||||
private string DeviceID;
|
||||
|
||||
@@ -39,20 +39,26 @@ namespace ArchiSteamFarm.IPC.Integration {
|
||||
private const byte MaxFailedAuthorizationAttempts = 5;
|
||||
|
||||
private static readonly SemaphoreSlim AuthorizationSemaphore = new SemaphoreSlim(1, 1);
|
||||
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
private static readonly Timer ClearFailedAuthorizationsTimer = new Timer(
|
||||
e => FailedAuthorizations.Clear(),
|
||||
null,
|
||||
TimeSpan.FromHours(FailedAuthorizationsCooldownInHours), // Delay
|
||||
TimeSpan.FromHours(FailedAuthorizationsCooldownInHours) // Period
|
||||
);
|
||||
|
||||
private static readonly ConcurrentDictionary<IPAddress, byte> FailedAuthorizations = new ConcurrentDictionary<IPAddress, byte>();
|
||||
|
||||
private static Timer ClearFailedAuthorizationsTimer;
|
||||
|
||||
private readonly RequestDelegate Next;
|
||||
|
||||
public ApiAuthenticationMiddleware([NotNull] RequestDelegate next) => Next = next ?? throw new ArgumentNullException(nameof(next));
|
||||
public ApiAuthenticationMiddleware([NotNull] RequestDelegate next) {
|
||||
Next = next ?? throw new ArgumentNullException(nameof(next));
|
||||
|
||||
lock (FailedAuthorizations) {
|
||||
if (ClearFailedAuthorizationsTimer == null) {
|
||||
ClearFailedAuthorizationsTimer = new Timer(
|
||||
e => FailedAuthorizations.Clear(),
|
||||
null,
|
||||
TimeSpan.FromHours(FailedAuthorizationsCooldownInHours), // Delay
|
||||
TimeSpan.FromHours(FailedAuthorizationsCooldownInHours) // Period
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public async Task InvokeAsync(HttpContext context) {
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace ArchiSteamFarm.Json {
|
||||
[PublicAPI]
|
||||
public EType Type { get; internal set; }
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "amount", Required = Required.Always)]
|
||||
[NotNull]
|
||||
private string AmountText {
|
||||
@@ -91,6 +92,7 @@ namespace ArchiSteamFarm.Json {
|
||||
Amount = amount;
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
[JsonProperty(PropertyName = "assetid", Required = Required.DisallowNull)]
|
||||
[NotNull]
|
||||
@@ -114,6 +116,7 @@ namespace ArchiSteamFarm.Json {
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "classid", Required = Required.DisallowNull)]
|
||||
[NotNull]
|
||||
private string ClassIDText {
|
||||
@@ -133,7 +136,9 @@ namespace ArchiSteamFarm.Json {
|
||||
ClassID = classID;
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "contextid", Required = Required.DisallowNull)]
|
||||
[NotNull]
|
||||
private string ContextIDText {
|
||||
@@ -155,13 +160,16 @@ namespace ArchiSteamFarm.Json {
|
||||
ContextID = contextID;
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "id", Required = Required.DisallowNull)]
|
||||
[NotNull]
|
||||
private string IDText {
|
||||
get => AssetIDText;
|
||||
set => AssetIDText = value;
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
// Constructed from trades being received or plugins
|
||||
public Asset(uint appID, ulong contextID, ulong classID, uint amount, bool marketable = true, uint realAppID = 0, EType type = EType.Unknown, ERarity rarity = ERarity.Unknown) {
|
||||
@@ -218,6 +226,7 @@ namespace ArchiSteamFarm.Json {
|
||||
internal ulong TradeOfferID { get; private set; }
|
||||
internal EType Type { get; private set; }
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "html", Required = Required.DisallowNull)]
|
||||
private string HTML {
|
||||
set {
|
||||
@@ -287,6 +296,7 @@ namespace ArchiSteamFarm.Json {
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
[JsonConstructor]
|
||||
private ConfirmationDetails() { }
|
||||
@@ -318,6 +328,7 @@ namespace ArchiSteamFarm.Json {
|
||||
[PublicAPI]
|
||||
public bool Success { get; private set; }
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "success", Required = Required.Always)]
|
||||
private byte SuccessNumber {
|
||||
set {
|
||||
@@ -337,6 +348,7 @@ namespace ArchiSteamFarm.Json {
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
[JsonConstructor]
|
||||
protected NumberResponse() { }
|
||||
@@ -418,6 +430,7 @@ namespace ArchiSteamFarm.Json {
|
||||
internal ulong LastAssetID { get; private set; }
|
||||
internal bool MoreItems { get; private set; }
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "last_assetid", Required = Required.DisallowNull)]
|
||||
private string LastAssetIDText {
|
||||
set {
|
||||
@@ -436,11 +449,14 @@ namespace ArchiSteamFarm.Json {
|
||||
LastAssetID = lastAssetID;
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "more_items", Required = Required.DisallowNull)]
|
||||
private byte MoreItemsNumber {
|
||||
set => MoreItems = value > 0;
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
[JsonConstructor]
|
||||
private InventoryResponse() { }
|
||||
@@ -456,6 +472,7 @@ namespace ArchiSteamFarm.Json {
|
||||
internal bool Tradable { get; private set; }
|
||||
internal Asset.EType Type { get; private set; }
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "classid", Required = Required.Always)]
|
||||
private string ClassIDText {
|
||||
set {
|
||||
@@ -474,12 +491,16 @@ namespace ArchiSteamFarm.Json {
|
||||
ClassID = classID;
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "marketable", Required = Required.Always)]
|
||||
private byte MarketableNumber {
|
||||
set => Marketable = value > 0;
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "tags", Required = Required.DisallowNull)]
|
||||
private ImmutableHashSet<Tag> Tags {
|
||||
set {
|
||||
@@ -492,11 +513,14 @@ namespace ArchiSteamFarm.Json {
|
||||
(Type, Rarity, RealAppID) = InterpretTags(value);
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "tradable", Required = Required.Always)]
|
||||
private byte TradableNumber {
|
||||
set => Tradable = value > 0;
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
[JsonConstructor]
|
||||
private Description() { }
|
||||
@@ -703,6 +727,7 @@ namespace ArchiSteamFarm.Json {
|
||||
|
||||
internal ulong TradeOfferID { get; private set; }
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "tradeofferid", Required = Required.Always)]
|
||||
private string TradeOfferIDText {
|
||||
set {
|
||||
@@ -721,6 +746,7 @@ namespace ArchiSteamFarm.Json {
|
||||
TradeOfferID = tradeOfferID;
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
[JsonConstructor]
|
||||
private TradeOfferSendResponse() { }
|
||||
|
||||
@@ -644,6 +644,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
internal bool MatchEverything { get; private set; }
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "matchable_backgrounds", Required = Required.Always)]
|
||||
private byte MatchableBackgroundsNumber {
|
||||
set {
|
||||
@@ -663,7 +664,9 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "matchable_cards", Required = Required.Always)]
|
||||
private byte MatchableCardsNumber {
|
||||
set {
|
||||
@@ -683,7 +686,9 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "matchable_emoticons", Required = Required.Always)]
|
||||
private byte MatchableEmoticonsNumber {
|
||||
set {
|
||||
@@ -703,7 +708,9 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "matchable_foil_cards", Required = Required.Always)]
|
||||
private byte MatchableFoilCardsNumber {
|
||||
set {
|
||||
@@ -723,7 +730,9 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
[JsonProperty(PropertyName = "match_everything", Required = Required.Always)]
|
||||
private byte MatchEverythingNumber {
|
||||
set {
|
||||
@@ -743,6 +752,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
[JsonConstructor]
|
||||
private ListedUser() { }
|
||||
|
||||
Reference in New Issue
Block a user