mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-11-10 07:04:27 +00:00
Revert "Resharper cleanup"
This reverts commit 7c8d7b5ada
.
Bad cleanup.
This commit is contained in:
parent
7c8d7b5ada
commit
fcf9686a79
33 changed files with 223 additions and 332 deletions
|
@ -106,7 +106,6 @@
|
||||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALLOW_COMMENT_AFTER_LBRACE/@EntryValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALLOW_COMMENT_AFTER_LBRACE/@EntryValue">True</s:Boolean>
|
||||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
|
||||||
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_AFTER_CONTROL_TRANSFER_STATEMENTS/@EntryValue">1</s:Int64>
|
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_AFTER_CONTROL_TRANSFER_STATEMENTS/@EntryValue">1</s:Int64>
|
||||||
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_AROUND_FIELD/@EntryValue">0</s:Int64>
|
|
||||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">END_OF_LINE</s:String>
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">END_OF_LINE</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EMPTY_BLOCK_STYLE/@EntryValue">TOGETHER_SAME_LINE</s:String>
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EMPTY_BLOCK_STYLE/@EntryValue">TOGETHER_SAME_LINE</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INITIALIZER_BRACES/@EntryValue">END_OF_LINE</s:String>
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INITIALIZER_BRACES/@EntryValue">END_OF_LINE</s:String>
|
||||||
|
|
|
@ -41,9 +41,7 @@ namespace ArchiSteamFarm {
|
||||||
|
|
||||||
internal DateTime LastPacketReceived { get; private set; } = DateTime.MinValue;
|
internal DateTime LastPacketReceived { get; private set; } = DateTime.MinValue;
|
||||||
|
|
||||||
internal ArchiHandler(ArchiLogger archiLogger) {
|
internal ArchiHandler(ArchiLogger archiLogger) => ArchiLogger = archiLogger ?? throw new ArgumentNullException(nameof(archiLogger));
|
||||||
ArchiLogger = archiLogger ?? throw new ArgumentNullException(nameof(archiLogger));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void HandleMsg(IPacketMsg packetMsg) {
|
public override void HandleMsg(IPacketMsg packetMsg) {
|
||||||
if (packetMsg == null) {
|
if (packetMsg == null) {
|
||||||
|
|
|
@ -188,8 +188,7 @@ namespace ArchiSteamFarm {
|
||||||
Bot.ArchiLogger.LogGenericWarningException(e);
|
Bot.ArchiLogger.LogGenericWarningException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}).ConfigureAwait(false);
|
||||||
.ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
|
@ -243,8 +242,7 @@ namespace ArchiSteamFarm {
|
||||||
Bot.ArchiLogger.LogGenericWarningException(e);
|
Bot.ArchiLogger.LogGenericWarningException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}).ConfigureAwait(false);
|
||||||
.ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
|
@ -627,8 +625,7 @@ namespace ArchiSteamFarm {
|
||||||
Bot.ArchiLogger.LogGenericWarningException(e);
|
Bot.ArchiLogger.LogGenericWarningException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}).ConfigureAwait(false);
|
||||||
.ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
|
@ -666,8 +663,7 @@ namespace ArchiSteamFarm {
|
||||||
Bot.ArchiLogger.LogGenericWarningException(e);
|
Bot.ArchiLogger.LogGenericWarningException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}).ConfigureAwait(false);
|
||||||
.ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
|
@ -810,13 +806,9 @@ namespace ArchiSteamFarm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<bool> HasValidApiKey() {
|
internal async Task<bool> HasValidApiKey() => !string.IsNullOrEmpty(await GetApiKey().ConfigureAwait(false));
|
||||||
return !string.IsNullOrEmpty(await GetApiKey().ConfigureAwait(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void Init() {
|
internal static void Init() => Timeout = Program.GlobalConfig.ConnectionTimeout * 1000;
|
||||||
Timeout = Program.GlobalConfig.ConnectionTimeout * 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal async Task<bool> Init(ulong steamID, EUniverse universe, string webAPIUserNonce, string parentalPin) {
|
internal async Task<bool> Init(ulong steamID, EUniverse universe, string webAPIUserNonce, string parentalPin) {
|
||||||
if ((steamID == 0) || (universe == EUniverse.Invalid) || string.IsNullOrEmpty(webAPIUserNonce) || string.IsNullOrEmpty(parentalPin)) {
|
if ((steamID == 0) || (universe == EUniverse.Invalid) || string.IsNullOrEmpty(webAPIUserNonce) || string.IsNullOrEmpty(parentalPin)) {
|
||||||
|
@ -862,8 +854,7 @@ namespace ArchiSteamFarm {
|
||||||
Bot.ArchiLogger.LogGenericWarningException(e);
|
Bot.ArchiLogger.LogGenericWarningException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}).ConfigureAwait(false);
|
||||||
.ConfigureAwait(false);
|
|
||||||
|
|
||||||
if (authResult == null) {
|
if (authResult == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -56,7 +56,6 @@ namespace ArchiSteamFarm {
|
||||||
|
|
||||||
private static readonly SemaphoreSlim GiftsSemaphore = new SemaphoreSlim(1);
|
private static readonly SemaphoreSlim GiftsSemaphore = new SemaphoreSlim(1);
|
||||||
private static readonly SemaphoreSlim LoginSemaphore = new SemaphoreSlim(1);
|
private static readonly SemaphoreSlim LoginSemaphore = new SemaphoreSlim(1);
|
||||||
|
|
||||||
internal readonly ArchiLogger ArchiLogger;
|
internal readonly ArchiLogger ArchiLogger;
|
||||||
internal readonly ArchiWebHandler ArchiWebHandler;
|
internal readonly ArchiWebHandler ArchiWebHandler;
|
||||||
internal readonly string BotName;
|
internal readonly string BotName;
|
||||||
|
@ -81,6 +80,7 @@ namespace ArchiSteamFarm {
|
||||||
private readonly Timer HeartBeatTimer;
|
private readonly Timer HeartBeatTimer;
|
||||||
private readonly SemaphoreSlim InitializationSemaphore = new SemaphoreSlim(1);
|
private readonly SemaphoreSlim InitializationSemaphore = new SemaphoreSlim(1);
|
||||||
private readonly ConcurrentHashSet<uint> OwnedPackageIDs = new ConcurrentHashSet<uint>();
|
private readonly ConcurrentHashSet<uint> OwnedPackageIDs = new ConcurrentHashSet<uint>();
|
||||||
|
|
||||||
private readonly Statistics Statistics;
|
private readonly Statistics Statistics;
|
||||||
private readonly SteamApps SteamApps;
|
private readonly SteamApps SteamApps;
|
||||||
private readonly SteamClient SteamClient;
|
private readonly SteamClient SteamClient;
|
||||||
|
@ -510,9 +510,7 @@ namespace ArchiSteamFarm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void OnFarmingStopped() {
|
internal void OnFarmingStopped() => ResetGamesPlayed();
|
||||||
ResetGamesPlayed();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal async Task OnNewConfigLoaded(ASF.BotConfigEventArgs args) {
|
internal async Task OnNewConfigLoaded(ASF.BotConfigEventArgs args) {
|
||||||
if (args == null) {
|
if (args == null) {
|
||||||
|
@ -546,9 +544,7 @@ namespace ArchiSteamFarm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void PlayGame(uint gameID, string gameName = null) {
|
internal void PlayGame(uint gameID, string gameName = null) => PlayGames(gameID.ToEnumerable(), gameName);
|
||||||
PlayGames(gameID.ToEnumerable(), gameName);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void PlayGames(IEnumerable<uint> gameIDs, string gameName = null) {
|
internal void PlayGames(IEnumerable<uint> gameIDs, string gameName = null) {
|
||||||
if (gameIDs == null) {
|
if (gameIDs == null) {
|
||||||
|
@ -846,7 +842,7 @@ namespace ArchiSteamFarm {
|
||||||
Task.Run(() => Stop()).Forget();
|
Task.Run(() => Stop()).Forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
Bots.TryRemove(BotName, out _);
|
Bots.TryRemove(BotName, out Bot _);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Disconnect() {
|
private void Disconnect() {
|
||||||
|
@ -925,9 +921,7 @@ namespace ArchiSteamFarm {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ulong GetFirstSteamMasterID() {
|
private ulong GetFirstSteamMasterID() => BotConfig.SteamUserPermissions.Where(kv => (kv.Key != 0) && (kv.Key != SteamID) && (kv.Value == BotConfig.EPermission.Master)).Select(kv => kv.Key).OrderBy(steamID => steamID).FirstOrDefault();
|
||||||
return BotConfig.SteamUserPermissions.Where(kv => (kv.Key != 0) && (kv.Key != SteamID) && (kv.Value == BotConfig.EPermission.Master)).Select(kv => kv.Key).OrderBy(steamID => steamID).FirstOrDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
private BotConfig.EPermission GetSteamUserPermission(ulong steamID) {
|
private BotConfig.EPermission GetSteamUserPermission(ulong steamID) {
|
||||||
if (steamID != 0) {
|
if (steamID != 0) {
|
||||||
|
@ -1204,8 +1198,7 @@ namespace ArchiSteamFarm {
|
||||||
Task.Run(async () => {
|
Task.Run(async () => {
|
||||||
await Task.Delay(Program.GlobalConfig.GiftsLimiterDelay * 1000).ConfigureAwait(false);
|
await Task.Delay(Program.GlobalConfig.GiftsLimiterDelay * 1000).ConfigureAwait(false);
|
||||||
GiftsSemaphore.Release();
|
GiftsSemaphore.Release();
|
||||||
})
|
}).Forget();
|
||||||
.Forget();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task LimitLoginRequestsAsync() {
|
private static async Task LimitLoginRequestsAsync() {
|
||||||
|
@ -1213,8 +1206,7 @@ namespace ArchiSteamFarm {
|
||||||
Task.Run(async () => {
|
Task.Run(async () => {
|
||||||
await Task.Delay(Program.GlobalConfig.LoginLimiterDelay * 1000).ConfigureAwait(false);
|
await Task.Delay(Program.GlobalConfig.LoginLimiterDelay * 1000).ConfigureAwait(false);
|
||||||
LoginSemaphore.Release();
|
LoginSemaphore.Release();
|
||||||
})
|
}).Forget();
|
||||||
.Forget();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task MarkInventoryIfNeeded() {
|
private async Task MarkInventoryIfNeeded() {
|
||||||
|
@ -1684,8 +1676,7 @@ namespace ArchiSteamFarm {
|
||||||
Task.Run(async () => {
|
Task.Run(async () => {
|
||||||
await ArchiWebHandler.JoinGroup(BotConfig.SteamMasterClanID).ConfigureAwait(false);
|
await ArchiWebHandler.JoinGroup(BotConfig.SteamMasterClanID).ConfigureAwait(false);
|
||||||
JoinMasterChat();
|
JoinMasterChat();
|
||||||
})
|
}).Forget();
|
||||||
.Forget();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Statistics?.OnLoggedOn().Forget();
|
Statistics?.OnLoggedOn().Forget();
|
||||||
|
@ -2310,8 +2301,7 @@ namespace ArchiSteamFarm {
|
||||||
Task.Run(async () => {
|
Task.Run(async () => {
|
||||||
await Task.Delay(1000).ConfigureAwait(false);
|
await Task.Delay(1000).ConfigureAwait(false);
|
||||||
await Program.Exit().ConfigureAwait(false);
|
await Program.Exit().ConfigureAwait(false);
|
||||||
})
|
}).Forget();
|
||||||
.Forget();
|
|
||||||
|
|
||||||
return FormatStaticResponse(Strings.Done);
|
return FormatStaticResponse(Strings.Done);
|
||||||
}
|
}
|
||||||
|
@ -3173,8 +3163,7 @@ namespace ArchiSteamFarm {
|
||||||
Task.Run(async () => {
|
Task.Run(async () => {
|
||||||
await Task.Delay(1000).ConfigureAwait(false);
|
await Task.Delay(1000).ConfigureAwait(false);
|
||||||
await Program.Restart().ConfigureAwait(false);
|
await Program.Restart().ConfigureAwait(false);
|
||||||
})
|
}).Forget();
|
||||||
.Forget();
|
|
||||||
|
|
||||||
return FormatStaticResponse(Strings.Done);
|
return FormatStaticResponse(Strings.Done);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,9 +95,7 @@ namespace ArchiSteamFarm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal IEnumerable<ulong> GetBlacklistedFromTradesSteamIDs() {
|
internal IEnumerable<ulong> GetBlacklistedFromTradesSteamIDs() => BlacklistedFromTradesSteamIDs;
|
||||||
return BlacklistedFromTradesSteamIDs;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal bool IsBlacklistedFromTrades(ulong steamID) {
|
internal bool IsBlacklistedFromTrades(ulong steamID) {
|
||||||
if (steamID != 0) {
|
if (steamID != 0) {
|
||||||
|
|
|
@ -42,9 +42,7 @@ namespace ArchiSteamFarm.CMsgs {
|
||||||
AcceptInvite = binaryReader.ReadBoolean();
|
AcceptInvite = binaryReader.ReadBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
EMsg ISteamSerializableMessage.GetEMsg() {
|
EMsg ISteamSerializableMessage.GetEMsg() => EMsg.ClientAcknowledgeClanInvite;
|
||||||
return EMsg.ClientAcknowledgeClanInvite;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ISteamSerializable.Serialize(Stream stream) {
|
void ISteamSerializable.Serialize(Stream stream) {
|
||||||
if (stream == null) {
|
if (stream == null) {
|
||||||
|
|
|
@ -90,9 +90,7 @@ namespace ArchiSteamFarm {
|
||||||
IdleFarmingTimer?.Dispose();
|
IdleFarmingTimer?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void OnDisconnected() {
|
internal void OnDisconnected() => StopFarming().Forget();
|
||||||
StopFarming().Forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal async Task OnNewGameAdded() {
|
internal async Task OnNewGameAdded() {
|
||||||
// If we're not farming yet, obviously it's worth it to make a check
|
// If we're not farming yet, obviously it's worth it to make a check
|
||||||
|
@ -148,9 +146,7 @@ namespace ArchiSteamFarm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SetInitialState(bool paused) {
|
internal void SetInitialState(bool paused) => StickyPause = Paused = paused;
|
||||||
StickyPause = Paused = paused;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal async Task StartFarming() {
|
internal async Task StartFarming() {
|
||||||
if (NowFarming || Paused || !Bot.IsPlayingPossible) {
|
if (NowFarming || Paused || !Bot.IsPlayingPossible) {
|
||||||
|
@ -848,13 +844,9 @@ namespace ArchiSteamFarm {
|
||||||
return (game != null) && Equals(game);
|
return (game != null) && Equals(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode() {
|
public override int GetHashCode() => (int) AppID;
|
||||||
return (int) AppID;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool Equals(Game other) {
|
private bool Equals(Game other) => AppID == other.AppID;
|
||||||
return AppID == other.AppID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -45,16 +45,8 @@ namespace ArchiSteamFarm {
|
||||||
Enumerator = collection.GetEnumerator();
|
Enumerator = collection.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() => Lock.Dispose();
|
||||||
Lock.Dispose();
|
public bool MoveNext() => Enumerator.MoveNext();
|
||||||
}
|
public void Reset() => Enumerator.Reset();
|
||||||
|
|
||||||
public bool MoveNext() {
|
|
||||||
return Enumerator.MoveNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Reset() {
|
|
||||||
Enumerator.Reset();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -72,9 +72,7 @@ namespace ArchiSteamFarm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator<T> GetEnumerator() {
|
public IEnumerator<T> GetEnumerator() => new ConcurrentEnumerator<T>(HashSet, Lock);
|
||||||
return new ConcurrentEnumerator<T>(HashSet, Lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void IntersectWith(IEnumerable<T> other) {
|
public void IntersectWith(IEnumerable<T> other) {
|
||||||
using (Lock.WriterLock()) {
|
using (Lock.WriterLock()) {
|
||||||
|
@ -136,13 +134,9 @@ namespace ArchiSteamFarm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICollection<T>.Add(T item) {
|
void ICollection<T>.Add(T item) => Add(item);
|
||||||
Add(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() {
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||||
return GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal bool AddRange(IEnumerable<T> items) {
|
internal bool AddRange(IEnumerable<T> items) {
|
||||||
using (Lock.WriterLock()) {
|
using (Lock.WriterLock()) {
|
||||||
|
|
|
@ -77,9 +77,7 @@ namespace ArchiSteamFarm {
|
||||||
ServerListProvider.ServerListUpdated += OnServerListUpdated;
|
ServerListProvider.ServerListUpdated += OnServerListUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() => ServerListProvider.ServerListUpdated -= OnServerListUpdated;
|
||||||
ServerListProvider.ServerListUpdated -= OnServerListUpdated;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static GlobalDatabase Load(string filePath) {
|
internal static GlobalDatabase Load(string filePath) {
|
||||||
if (string.IsNullOrEmpty(filePath)) {
|
if (string.IsNullOrEmpty(filePath)) {
|
||||||
|
@ -109,9 +107,7 @@ namespace ArchiSteamFarm {
|
||||||
return globalDatabase;
|
return globalDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnServerListUpdated(object sender, EventArgs e) {
|
private void OnServerListUpdated(object sender, EventArgs e) => Save();
|
||||||
Save();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Save() {
|
private void Save() {
|
||||||
string json = JsonConvert.SerializeObject(this, CustomSerializerSettings);
|
string json = JsonConvert.SerializeObject(this, CustomSerializerSettings);
|
||||||
|
|
|
@ -29,9 +29,7 @@ using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace ArchiSteamFarm {
|
namespace ArchiSteamFarm {
|
||||||
internal sealed class IPAddressConverter : JsonConverter {
|
internal sealed class IPAddressConverter : JsonConverter {
|
||||||
public override bool CanConvert(Type objectType) {
|
public override bool CanConvert(Type objectType) => objectType == typeof(IPAddress);
|
||||||
return objectType == typeof(IPAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
|
||||||
JToken token = JToken.Load(reader);
|
JToken token = JToken.Load(reader);
|
||||||
|
|
|
@ -29,9 +29,7 @@ using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace ArchiSteamFarm {
|
namespace ArchiSteamFarm {
|
||||||
internal sealed class IPEndPointConverter : JsonConverter {
|
internal sealed class IPEndPointConverter : JsonConverter {
|
||||||
public override bool CanConvert(Type objectType) {
|
public override bool CanConvert(Type objectType) => objectType == typeof(IPEndPoint);
|
||||||
return objectType == typeof(IPEndPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
|
||||||
JObject jo = JObject.Load(reader);
|
JObject jo = JObject.Load(reader);
|
||||||
|
|
|
@ -34,9 +34,7 @@ namespace ArchiSteamFarm {
|
||||||
[JsonProperty(Required = Required.DisallowNull)]
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
private readonly ConcurrentHashSet<IPEndPoint> Servers = new ConcurrentHashSet<IPEndPoint>();
|
private readonly ConcurrentHashSet<IPEndPoint> Servers = new ConcurrentHashSet<IPEndPoint>();
|
||||||
|
|
||||||
public Task<IEnumerable<IPEndPoint>> FetchServerListAsync() {
|
public Task<IEnumerable<IPEndPoint>> FetchServerListAsync() => Task.FromResult<IEnumerable<IPEndPoint>>(Servers);
|
||||||
return Task.FromResult<IEnumerable<IPEndPoint>>(Servers);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task UpdateServerListAsync(IEnumerable<IPEndPoint> endPoints) {
|
public Task UpdateServerListAsync(IEnumerable<IPEndPoint> endPoints) {
|
||||||
if (endPoints == null) {
|
if (endPoints == null) {
|
||||||
|
|
|
@ -489,9 +489,7 @@ namespace ArchiSteamFarm.JSON {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool IsSteamCardsRequest() {
|
internal bool IsSteamCardsRequest() => ItemsToGive.All(item => (item.AppID == Item.SteamAppID) && (item.ContextID == Item.SteamCommunityContextID) && (item.Type == Item.EType.TradingCard));
|
||||||
return ItemsToGive.All(item => (item.AppID == Item.SteamAppID) && (item.ContextID == Item.SteamCommunityContextID) && (item.Type == Item.EType.TradingCard));
|
|
||||||
}
|
|
||||||
|
|
||||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||||
internal enum ETradeOfferState : byte {
|
internal enum ETradeOfferState : byte {
|
||||||
|
|
|
@ -68,9 +68,7 @@ namespace ArchiSteamFarm {
|
||||||
|
|
||||||
private MobileAuthenticator() { }
|
private MobileAuthenticator() { }
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() => ConfirmationsSemaphore.Dispose();
|
||||||
ConfirmationsSemaphore.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void CorrectDeviceID(string deviceID) {
|
internal void CorrectDeviceID(string deviceID) {
|
||||||
if (string.IsNullOrEmpty(deviceID)) {
|
if (string.IsNullOrEmpty(deviceID)) {
|
||||||
|
@ -248,9 +246,7 @@ namespace ArchiSteamFarm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Init(Bot bot) {
|
internal void Init(Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));
|
||||||
Bot = bot ?? throw new ArgumentNullException(nameof(bot));
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static async Task OnTimeChanged() {
|
internal static async Task OnTimeChanged() {
|
||||||
await TimeSemaphore.WaitAsync().ConfigureAwait(false);
|
await TimeSemaphore.WaitAsync().ConfigureAwait(false);
|
||||||
|
|
|
@ -77,9 +77,7 @@ namespace ArchiSteamFarm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async void OnTimeChanged(object sender, EventArgs e) {
|
private static async void OnTimeChanged(object sender, EventArgs e) => await MobileAuthenticator.OnTimeChanged().ConfigureAwait(false);
|
||||||
await MobileAuthenticator.OnTimeChanged().ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class NativeMethods {
|
private static class NativeMethods {
|
||||||
internal const uint EnableQuickEditMode = 0x0040;
|
internal const uint EnableQuickEditMode = 0x0040;
|
||||||
|
|
|
@ -446,8 +446,7 @@ namespace ArchiSteamFarm {
|
||||||
ServiceName = SharedInfo.ServiceName;
|
ServiceName = SharedInfo.ServiceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnStart(string[] args) {
|
protected override void OnStart(string[] args) => Task.Run(async () => {
|
||||||
Task.Run(async () => {
|
|
||||||
// Normally it'd make sense to use already provided string[] args parameter above
|
// Normally it'd make sense to use already provided string[] args parameter above
|
||||||
// However, that one doesn't seem to work when ASF is started as a service, it's always null
|
// However, that one doesn't seem to work when ASF is started as a service, it's always null
|
||||||
// Therefore, we will use Environment args in such case
|
// Therefore, we will use Environment args in such case
|
||||||
|
@ -457,11 +456,8 @@ namespace ArchiSteamFarm {
|
||||||
ShutdownResetEvent.Wait();
|
ShutdownResetEvent.Wait();
|
||||||
Stop();
|
Stop();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
protected override async void OnStop() {
|
protected override async void OnStop() => await Shutdown().ConfigureAwait(false);
|
||||||
await Shutdown().ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -48,13 +48,9 @@ namespace ArchiSteamFarm {
|
||||||
private DateTime LastPersonaStateRequest = DateTime.MinValue;
|
private DateTime LastPersonaStateRequest = DateTime.MinValue;
|
||||||
private bool ShouldSendHeartBeats;
|
private bool ShouldSendHeartBeats;
|
||||||
|
|
||||||
internal Statistics(Bot bot) {
|
internal Statistics(Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));
|
||||||
Bot = bot ?? throw new ArgumentNullException(nameof(bot));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() => Semaphore.Dispose();
|
||||||
Semaphore.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal async Task OnHeartBeat() {
|
internal async Task OnHeartBeat() {
|
||||||
// Request persona update if needed
|
// Request persona update if needed
|
||||||
|
@ -89,9 +85,7 @@ namespace ArchiSteamFarm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task OnLoggedOn() {
|
internal async Task OnLoggedOn() => await Bot.ArchiWebHandler.JoinGroup(SharedInfo.ASFGroupSteamID).ConfigureAwait(false);
|
||||||
await Bot.ArchiWebHandler.JoinGroup(SharedInfo.ASFGroupSteamID).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal async Task OnPersonaState(SteamFriends.PersonaStateCallback callback) {
|
internal async Task OnPersonaState(SteamFriends.PersonaStateCallback callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
|
|
|
@ -43,13 +43,9 @@ namespace ArchiSteamFarm {
|
||||||
|
|
||||||
private bool ParsingScheduled;
|
private bool ParsingScheduled;
|
||||||
|
|
||||||
internal Trading(Bot bot) {
|
internal Trading(Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));
|
||||||
Bot = bot ?? throw new ArgumentNullException(nameof(bot));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() => TradesSemaphore.Dispose();
|
||||||
TradesSemaphore.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal async Task CheckTrades() {
|
internal async Task CheckTrades() {
|
||||||
// We aim to have a maximum of 2 tasks, one already parsing, and one waiting in the queue
|
// We aim to have a maximum of 2 tasks, one already parsing, and one waiting in the queue
|
||||||
|
@ -80,13 +76,10 @@ namespace ArchiSteamFarm {
|
||||||
Task.Run(async () => {
|
Task.Run(async () => {
|
||||||
await Task.Delay(Program.GlobalConfig.InventoryLimiterDelay * 1000).ConfigureAwait(false);
|
await Task.Delay(Program.GlobalConfig.InventoryLimiterDelay * 1000).ConfigureAwait(false);
|
||||||
InventorySemaphore.Release();
|
InventorySemaphore.Release();
|
||||||
})
|
}).Forget();
|
||||||
.Forget();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void OnDisconnected() {
|
internal void OnDisconnected() => IgnoredTrades.ClearAndTrim();
|
||||||
IgnoredTrades.ClearAndTrim();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task ParseActiveTrades() {
|
private async Task ParseActiveTrades() {
|
||||||
HashSet<Steam.TradeOffer> tradeOffers = await Bot.ArchiWebHandler.GetActiveTradeOffers().ConfigureAwait(false);
|
HashSet<Steam.TradeOffer> tradeOffers = await Bot.ArchiWebHandler.GetActiveTradeOffers().ConfigureAwait(false);
|
||||||
|
|
|
@ -68,9 +68,7 @@ namespace ArchiSteamFarm {
|
||||||
return cookies.Count != 0 ? (from Cookie cookie in cookies where cookie.Name.Equals(name) select cookie.Value).FirstOrDefault() : null;
|
return cookies.Count != 0 ? (from Cookie cookie in cookies where cookie.Name.Equals(name) select cookie.Value).FirstOrDefault() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static uint GetUnixTime() {
|
internal static uint GetUnixTime() => (uint) DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
||||||
return (uint) DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
internal static int RandomNext(int maxWithout) {
|
internal static int RandomNext(int maxWithout) {
|
||||||
|
@ -99,7 +97,7 @@ namespace ArchiSteamFarm {
|
||||||
for (byte i = 0; i < text.Length; i += split) {
|
for (byte i = 0; i < text.Length; i += split) {
|
||||||
string textPart = string.Join("", text.Skip(i).Take(split));
|
string textPart = string.Join("", text.Skip(i).Take(split));
|
||||||
|
|
||||||
if (!ulong.TryParse(textPart, NumberStyles.HexNumber, null, out _)) {
|
if (!ulong.TryParse(textPart, NumberStyles.HexNumber, null, out ulong _)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,9 +50,7 @@ namespace ArchiSteamFarm {
|
||||||
StopServer();
|
StopServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetStatus() {
|
public string GetStatus() => Program.GlobalConfig.SteamOwnerID == 0 ? "{}" : Bot.GetAPIStatus(Bot.Bots);
|
||||||
return Program.GlobalConfig.SteamOwnerID == 0 ? "{}" : Bot.GetAPIStatus(Bot.Bots);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string HandleCommand(string input) {
|
public string HandleCommand(string input) {
|
||||||
if (string.IsNullOrEmpty(input)) {
|
if (string.IsNullOrEmpty(input)) {
|
||||||
|
|
|
@ -305,11 +305,7 @@ namespace ArchiSteamFarm {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !__MonoCS__
|
#if !__MonoCS__
|
||||||
|
private static void InitNonMonoBehaviour() => ServicePointManager.ReusePort = true;
|
||||||
private static void InitNonMonoBehaviour() {
|
|
||||||
ServicePointManager.ReusePort = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private async Task<byte[]> UrlGetToBytes(string request, string referer = null) {
|
private async Task<byte[]> UrlGetToBytes(string request, string referer = null) {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Costura.Fody" version="2.0.0-beta0018" targetFramework="net461" developmentDependency="true" />
|
<package id="Costura.Fody" version="2.0.0-beta0018" targetFramework="net461" developmentDependency="true" />
|
||||||
<package id="Fody" version="1.30.0-beta01" targetFramework="net461" developmentDependency="true" />
|
<package id="Fody" version="1.30.0-beta01" targetFramework="net461" developmentDependency="true" />
|
||||||
|
|
|
@ -39,8 +39,6 @@ namespace ConfigGenerator {
|
||||||
Controls.Add(enhancedPropertyGrid);
|
Controls.Add(enhancedPropertyGrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RefreshText() {
|
internal void RefreshText() => Text = Path.GetFileNameWithoutExtension(ASFConfig.FilePath);
|
||||||
Text = Path.GetFileNameWithoutExtension(ASFConfig.FilePath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -68,9 +68,7 @@ namespace ConfigGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the current bit value corresponding to all checked items
|
// Gets the current bit value corresponding to all checked items
|
||||||
private int GetCurrentValue() {
|
private int GetCurrentValue() => (from object t in Items select t as FlagCheckedListBoxItem).Where((item, i) => (item != null) && GetItemChecked(i)).Aggregate(0, (current, item) => current | item.Value);
|
||||||
return (from object t in Items select t as FlagCheckedListBoxItem).Where((item, i) => (item != null) && GetItemChecked(i)).Aggregate(0, (current, item) => current | item.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Component Designer generated code
|
#region Component Designer generated code
|
||||||
|
|
||||||
|
@ -148,9 +146,7 @@ namespace ConfigGenerator {
|
||||||
Caption = c;
|
Caption = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() {
|
public override string ToString() => Caption;
|
||||||
return Caption;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UITypeEditor for flag enums
|
// UITypeEditor for flag enums
|
||||||
|
@ -179,8 +175,6 @@ namespace ConfigGenerator {
|
||||||
return FlagEnumCb.EnumValue;
|
return FlagEnumCb.EnumValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) {
|
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) => UITypeEditorEditStyle.DropDown;
|
||||||
return UITypeEditorEditStyle.DropDown;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Costura.Fody" version="2.0.0-beta0018" targetFramework="net461" developmentDependency="true" />
|
<package id="Costura.Fody" version="2.0.0-beta0018" targetFramework="net461" developmentDependency="true" />
|
||||||
<package id="Fody" version="1.30.0-beta01" targetFramework="net461" developmentDependency="true" />
|
<package id="Fody" version="1.30.0-beta01" targetFramework="net461" developmentDependency="true" />
|
||||||
|
|
|
@ -40,8 +40,6 @@ namespace ArchiSteamFarm {
|
||||||
AvatarPictureBox.LoadAsync();
|
AvatarPictureBox.LoadAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AvatarPictureBox_LoadCompleted(object sender, AsyncCompletedEventArgs e) {
|
private void AvatarPictureBox_LoadCompleted(object sender, AsyncCompletedEventArgs e) => MainForm.UpdateBotAvatar(Bot.BotName, AvatarPictureBox.Image);
|
||||||
MainForm.UpdateBotAvatar(Bot.BotName, AvatarPictureBox.Image);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -57,9 +57,7 @@ namespace ArchiSteamFarm {
|
||||||
BotStatusForm.BotForms[PreviouslySelectedBotName].Visible = true;
|
BotStatusForm.BotForms[PreviouslySelectedBotName].Visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
|
private async void MainForm_FormClosed(object sender, FormClosedEventArgs e) => await Program.InitShutdownSequence().ConfigureAwait(false);
|
||||||
await Program.InitShutdownSequence().ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void MainForm_Load(object sender, EventArgs e) {
|
private async void MainForm_Load(object sender, EventArgs e) {
|
||||||
BotListView.LargeImageList = BotListView.SmallImageList = AvatarImageList;
|
BotListView.LargeImageList = BotListView.SmallImageList = AvatarImageList;
|
||||||
|
|
|
@ -29,9 +29,7 @@ namespace ArchiSteamFarm {
|
||||||
Application.Exit();
|
Application.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetUserInput(ASF.EUserInputType userInputType, string botName = SharedInfo.ASF, string extraInformation = null) {
|
internal static string GetUserInput(ASF.EUserInputType userInputType, string botName = SharedInfo.ASF, string extraInformation = null) => null; // TODO
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static async Task InitASF() {
|
internal static async Task InitASF() {
|
||||||
ASF.ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version);
|
ASF.ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Costura.Fody" version="2.0.0-beta0018" targetFramework="net461" developmentDependency="true" />
|
<package id="Costura.Fody" version="2.0.0-beta0018" targetFramework="net461" developmentDependency="true" />
|
||||||
<package id="Fody" version="1.30.0-beta01" targetFramework="net461" developmentDependency="true" />
|
<package id="Fody" version="1.30.0-beta01" targetFramework="net461" developmentDependency="true" />
|
||||||
|
|
Loading…
Reference in a new issue