mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-26 11:16:47 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
feb3fbfe59 | ||
|
|
0b06df4352 | ||
|
|
10b1d02a95 | ||
|
|
7731360f09 | ||
|
|
02d3454d1b | ||
|
|
54b8d3e6f3 | ||
|
|
0b65e1d9a1 | ||
|
|
1f5005f14d | ||
|
|
6414f375fd |
@@ -10,6 +10,7 @@
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=FS/@EntryIndexedValue">FS</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HTML/@EntryIndexedValue">HTML</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IP/@EntryIndexedValue">IP</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OK/@EntryIndexedValue">OK</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PIN/@EntryIndexedValue">PIN</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SC/@EntryIndexedValue">SC</s:String>
|
||||
|
||||
@@ -46,6 +46,8 @@ namespace ArchiSteamFarm {
|
||||
// System account, requires admin privilege to install
|
||||
serviceProcessInstaller.Account = ServiceAccount.LocalSystem;
|
||||
|
||||
serviceInstaller.Installers.Clear();
|
||||
|
||||
EventLogInstaller logInstaller = new EventLogInstaller {
|
||||
Log = SharedInfo.EventLog,
|
||||
Source = SharedInfo.EventLogSource
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
<Compile Include="JSON\GitHub.cs" />
|
||||
<Compile Include="JSON\Steam.cs" />
|
||||
<Compile Include="Logging.cs" />
|
||||
<Compile Include="JsonStorageServerListProvider.cs" />
|
||||
<Compile Include="InMemoryServerListProvider.cs" />
|
||||
<Compile Include="MobileAuthenticator.cs" />
|
||||
<Compile Include="Runtime.cs" />
|
||||
<Compile Include="ObsoleteSteamGuardAccount.cs" />
|
||||
|
||||
@@ -377,11 +377,8 @@ namespace ArchiSteamFarm {
|
||||
string request = SteamCommunityURL + "/my/games/?xml=1";
|
||||
|
||||
XmlDocument response = await WebBrowser.UrlGetToXMLRetry(request).ConfigureAwait(false);
|
||||
if (response == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
XmlNodeList xmlNodeList = response.SelectNodes("gamesList/games/game");
|
||||
XmlNodeList xmlNodeList = response?.SelectNodes("gamesList/games/game");
|
||||
if ((xmlNodeList == null) || (xmlNodeList.Count == 0)) {
|
||||
return null;
|
||||
}
|
||||
@@ -492,11 +489,8 @@ namespace ArchiSteamFarm {
|
||||
string request = SteamCommunityURL + "/tradeoffer/" + tradeID + "?l=english";
|
||||
|
||||
HtmlDocument htmlDocument = await WebBrowser.UrlGetToHtmlDocumentRetry(request).ConfigureAwait(false);
|
||||
if (htmlDocument == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
HtmlNode htmlNode = htmlDocument.DocumentNode.SelectSingleNode("//div[@class='pagecontent']/script");
|
||||
HtmlNode htmlNode = htmlDocument?.DocumentNode.SelectSingleNode("//div[@class='pagecontent']/script");
|
||||
if (htmlNode == null) { // Trade can be no longer valid
|
||||
return null;
|
||||
}
|
||||
@@ -713,11 +707,8 @@ namespace ArchiSteamFarm {
|
||||
string request = SteamCommunityURL + "/my/inventory/json/" + Steam.Item.SteamAppID + "/" + Steam.Item.SteamContextID + "?trading=" + (tradable ? "1" : "0") + "&start=" + currentPage;
|
||||
|
||||
JObject jObject = await WebBrowser.UrlGetToJObjectRetry(request).ConfigureAwait(false);
|
||||
if (jObject == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IEnumerable<JToken> descriptions = jObject.SelectTokens("$.rgDescriptions.*");
|
||||
IEnumerable<JToken> descriptions = jObject?.SelectTokens("$.rgDescriptions.*");
|
||||
if (descriptions == null) {
|
||||
return null; // OK, empty inventory
|
||||
}
|
||||
@@ -913,11 +904,7 @@ namespace ArchiSteamFarm {
|
||||
string request = SteamCommunityURL + "/my/videos";
|
||||
|
||||
Uri uri = await WebBrowser.UrlHeadToUriRetry(request).ConfigureAwait(false);
|
||||
if (uri == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return !uri.AbsolutePath.StartsWith("/login", StringComparison.Ordinal);
|
||||
return !uri?.AbsolutePath.StartsWith("/login", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private async Task<bool> RefreshSessionIfNeeded() {
|
||||
|
||||
@@ -252,25 +252,11 @@ namespace ArchiSteamFarm {
|
||||
LoginSemaphore.Dispose();
|
||||
HandledGifts.Dispose();
|
||||
|
||||
if (AcceptConfirmationsTimer != null) {
|
||||
AcceptConfirmationsTimer.Dispose();
|
||||
}
|
||||
|
||||
if (ArchiWebHandler != null) {
|
||||
ArchiWebHandler.Dispose();
|
||||
}
|
||||
|
||||
if (CardsFarmer != null) {
|
||||
CardsFarmer.Dispose();
|
||||
}
|
||||
|
||||
if (SendItemsTimer != null) {
|
||||
SendItemsTimer.Dispose();
|
||||
}
|
||||
|
||||
if (Trading != null) {
|
||||
Trading.Dispose();
|
||||
}
|
||||
AcceptConfirmationsTimer?.Dispose();
|
||||
ArchiWebHandler?.Dispose();
|
||||
CardsFarmer?.Dispose();
|
||||
SendItemsTimer?.Dispose();
|
||||
Trading?.Dispose();
|
||||
}
|
||||
|
||||
internal async Task AcceptConfirmations(bool accept, Steam.ConfirmationDetails.EType acceptedType = Steam.ConfirmationDetails.EType.Unknown, ulong acceptedSteamID = 0, HashSet<ulong> acceptedTradeIDs = null) {
|
||||
@@ -333,7 +319,7 @@ namespace ArchiSteamFarm {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((callback == null) || string.IsNullOrEmpty(callback.Nonce)) {
|
||||
if (string.IsNullOrEmpty(callback?.Nonce)) {
|
||||
Start().Forget();
|
||||
return false;
|
||||
}
|
||||
@@ -1609,7 +1595,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
private async void OnGuestPassList(SteamApps.GuestPassListCallback callback) {
|
||||
if ((callback == null) || (callback.GuestPasses == null)) {
|
||||
if (callback?.GuestPasses == null) {
|
||||
Logging.LogNullError(nameof(callback) + " || " + nameof(callback.GuestPasses), BotName);
|
||||
return;
|
||||
}
|
||||
@@ -1647,7 +1633,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
private void OnChatInvite(SteamFriends.ChatInviteCallback callback) {
|
||||
if ((callback == null) || (callback.ChatRoomID == null) || (callback.PatronID == null)) {
|
||||
if ((callback?.ChatRoomID == null) || (callback.PatronID == null)) {
|
||||
Logging.LogNullError(nameof(callback) + " || " + nameof(callback.ChatRoomID) + " || " + nameof(callback.PatronID), BotName);
|
||||
return;
|
||||
}
|
||||
@@ -1689,7 +1675,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
private void OnFriendsList(SteamFriends.FriendsListCallback callback) {
|
||||
if ((callback == null) || (callback.FriendList == null)) {
|
||||
if (callback?.FriendList == null) {
|
||||
Logging.LogNullError(nameof(callback) + " || " + nameof(callback.FriendList), BotName);
|
||||
return;
|
||||
}
|
||||
@@ -1722,7 +1708,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
private async void OnFriendMsgHistory(SteamFriends.FriendMsgHistoryCallback callback) {
|
||||
if ((callback == null) || (callback.Messages == null) || (callback.SteamID == null)) {
|
||||
if ((callback?.Messages == null) || (callback.SteamID == null)) {
|
||||
Logging.LogNullError(nameof(callback) + " || " + nameof(callback.Messages) + " || " + nameof(callback.SteamID), BotName);
|
||||
return;
|
||||
}
|
||||
@@ -1795,7 +1781,7 @@ namespace ArchiSteamFarm {
|
||||
break;
|
||||
case EResult.InvalidPassword:
|
||||
InvalidPassword = true;
|
||||
Logging.LogGenericWarning("Unable to login to Steam: " + callback.Result, BotName);
|
||||
Logging.LogGenericWarning("Unable to login to Steam: " + callback.Result + " / " + callback.ExtendedResult, BotName);
|
||||
break;
|
||||
case EResult.OK:
|
||||
Logging.LogGenericInfo("Successfully logged on!", BotName);
|
||||
@@ -1855,17 +1841,17 @@ namespace ArchiSteamFarm {
|
||||
case EResult.ServiceUnavailable:
|
||||
case EResult.Timeout:
|
||||
case EResult.TryAnotherCM:
|
||||
Logging.LogGenericWarning("Unable to login to Steam: " + callback.Result, BotName);
|
||||
Logging.LogGenericWarning("Unable to login to Steam: " + callback.Result + " / " + callback.ExtendedResult, BotName);
|
||||
break;
|
||||
default: // Unexpected result, shutdown immediately
|
||||
Logging.LogGenericError("Unable to login to Steam: " + callback.Result, BotName);
|
||||
Logging.LogGenericError("Unable to login to Steam: " + callback.Result + " / " + callback.ExtendedResult, BotName);
|
||||
Stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLoginKey(SteamUser.LoginKeyCallback callback) {
|
||||
if ((callback == null) || string.IsNullOrEmpty(callback.LoginKey)) {
|
||||
if (string.IsNullOrEmpty(callback?.LoginKey)) {
|
||||
Logging.LogNullError(nameof(callback) + " || " + nameof(callback.LoginKey), BotName);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -75,9 +75,7 @@ namespace ArchiSteamFarm {
|
||||
FarmResetEvent.Dispose();
|
||||
FarmingSemaphore.Dispose();
|
||||
|
||||
if (Timer != null) {
|
||||
Timer.Dispose();
|
||||
}
|
||||
Timer?.Dispose();
|
||||
}
|
||||
|
||||
internal async Task SwitchToManualMode(bool manualMode) {
|
||||
|
||||
@@ -50,10 +50,6 @@ namespace ArchiSteamFarm {
|
||||
public bool MoveNext() => Enumerator.MoveNext();
|
||||
public void Reset() => Enumerator.Reset();
|
||||
|
||||
public void Dispose() {
|
||||
if (Lock != null) {
|
||||
Lock.ExitReadLock();
|
||||
}
|
||||
}
|
||||
public void Dispose() => Lock?.ExitReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,11 +100,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
if (Lock != null) {
|
||||
Lock.Dispose();
|
||||
}
|
||||
}
|
||||
public void Dispose() => Lock?.Dispose();
|
||||
|
||||
public void CopyTo(T[] array, int arrayIndex) {
|
||||
Lock.EnterReadLock();
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")]
|
||||
internal JsonStorageServerListProvider ServerListProvider { get; private set; } = new JsonStorageServerListProvider();
|
||||
internal InMemoryServerListProvider ServerListProvider { get; private set; } = new InMemoryServerListProvider();
|
||||
|
||||
private readonly object FileLock = new object();
|
||||
|
||||
@@ -91,14 +91,7 @@ namespace ArchiSteamFarm {
|
||||
return globalDatabase;
|
||||
}
|
||||
|
||||
private void OnServerListUpdated(object sender, EventArgs e) {
|
||||
if ((sender == null) || (e == null)) {
|
||||
Logging.LogNullError(nameof(sender) + " || " + nameof(e));
|
||||
return;
|
||||
}
|
||||
|
||||
Save();
|
||||
}
|
||||
private void OnServerListUpdated(object sender, EventArgs e) => Save();
|
||||
|
||||
// This constructor is used when creating new database
|
||||
private GlobalDatabase(string filePath) : this() {
|
||||
|
||||
@@ -25,21 +25,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using SteamKit2.Discovery;
|
||||
|
||||
namespace ArchiSteamFarm {
|
||||
internal sealed class JsonStorageServerListProvider : IServerListProvider {
|
||||
internal sealed class InMemoryServerListProvider : IServerListProvider {
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
[SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Local")]
|
||||
private HashSet<IPEndPoint> Servers = new HashSet<IPEndPoint>();
|
||||
|
||||
internal event EventHandler ServerListUpdated = delegate { };
|
||||
|
||||
public Task<IEnumerable<IPEndPoint>> FetchServerListAsync() => Task.FromResult(Servers.Select(endpoint => endpoint));
|
||||
public Task<IEnumerable<IPEndPoint>> FetchServerListAsync() => Task.FromResult<IEnumerable<IPEndPoint>>(Servers);
|
||||
|
||||
public Task UpdateServerListAsync(IEnumerable<IPEndPoint> endpoints) {
|
||||
if (endpoints == null) {
|
||||
@@ -173,11 +173,8 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
HtmlDocument htmlDocument = await Bot.ArchiWebHandler.GetConfirmations(DeviceID, confirmationHash, time).ConfigureAwait(false);
|
||||
if (htmlDocument == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
HtmlNodeCollection confirmationNodes = htmlDocument.DocumentNode.SelectNodes("//div[@class='mobileconf_list_entry']");
|
||||
HtmlNodeCollection confirmationNodes = htmlDocument?.DocumentNode.SelectNodes("//div[@class='mobileconf_list_entry']");
|
||||
if (confirmationNodes == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -437,8 +437,8 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) {
|
||||
if ((sender == null) || (args == null) || (args.ExceptionObject == null)) {
|
||||
Logging.LogNullError(nameof(sender) + " || " + nameof(args) + " || " + nameof(args.ExceptionObject));
|
||||
if (args?.ExceptionObject == null) {
|
||||
Logging.LogNullError(nameof(args) + " || " + nameof(args.ExceptionObject));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -446,8 +446,8 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs args) {
|
||||
if ((sender == null) || (args == null) || (args.Exception == null)) {
|
||||
Logging.LogNullError(nameof(sender) + " || " + nameof(args) + " || " + nameof(args.Exception));
|
||||
if (args?.Exception == null) {
|
||||
Logging.LogNullError(nameof(args) + " || " + nameof(args.Exception));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
namespace ArchiSteamFarm {
|
||||
internal static class SharedInfo {
|
||||
internal const string Version = "2.1.2.3";
|
||||
internal const string Version = "2.1.2.4";
|
||||
internal const string Copyright = "Copyright © ArchiSteamFarm 2015-2016";
|
||||
|
||||
internal const string GithubRepo = "JustArchi/ArchiSteamFarm";
|
||||
|
||||
@@ -75,13 +75,8 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
if (ServiceHost != null) {
|
||||
ServiceHost.Close();
|
||||
}
|
||||
|
||||
if (Client != null) {
|
||||
Client.Close();
|
||||
}
|
||||
ServiceHost?.Close();
|
||||
Client?.Close();
|
||||
}
|
||||
|
||||
internal bool IsServerRunning() => ServiceHost != null;
|
||||
|
||||
@@ -365,7 +365,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
using (HttpResponseMessage response = await UrlHeadToResponse(request, referer).ConfigureAwait(false)) {
|
||||
return response == null ? null : response.RequestMessage.RequestUri;
|
||||
return response?.RequestMessage.RequestUri;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,4 +6,4 @@ If my issue is not meeting contributing guidelines specified above, especially i
|
||||
|
||||
-----
|
||||
|
||||
Feel free to remove everything made up to this point, after all you're not being in a primary school.
|
||||
Now that you read and understood the notice, feel free to remove it and fill with real issue.
|
||||
|
||||
Reference in New Issue
Block a user