mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Code review
This commit is contained in:
@@ -62,7 +62,7 @@ namespace ArchiSteamFarm {
|
||||
byte[] sessionKey = CryptoHelper.GenerateRandomBlock(32);
|
||||
|
||||
// RSA encrypt it with the public key for the universe we're on
|
||||
byte[] cryptedSessionKey = null;
|
||||
byte[] cryptedSessionKey;
|
||||
using (RSACrypto rsa = new RSACrypto(KeyDictionary.GetPublicKey(steamClient.ConnectedUniverse))) {
|
||||
cryptedSessionKey = rsa.Encrypt(sessionKey);
|
||||
}
|
||||
@@ -368,7 +368,7 @@ namespace ArchiSteamFarm {
|
||||
{"partner", partnerID.ToString()},
|
||||
{"tradeoffermessage", "Sent by ASF"},
|
||||
{"json_tradeoffer", JsonConvert.SerializeObject(trade)},
|
||||
{"trade_offer_create_params", string.IsNullOrEmpty(token) ? "" : string.Format("{{ \"trade_offer_access_token\":\"{0}\" }}", token)} // TODO: This should be rewrote
|
||||
{"trade_offer_create_params", string.IsNullOrEmpty(token) ? "" : $"{{\"trade_offer_access_token\":\"{token}\"}}"}
|
||||
};
|
||||
|
||||
HttpResponseMessage response = null;
|
||||
@@ -466,13 +466,20 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
foreach (string setCookieValue in setCookieValues) {
|
||||
if (setCookieValue.Contains("steamparental=")) {
|
||||
string setCookie = setCookieValue.Substring(setCookieValue.IndexOf("steamparental=") + 14);
|
||||
setCookie = setCookie.Substring(0, setCookie.IndexOf(';'));
|
||||
Cookie["steamparental"] = setCookie;
|
||||
Logging.LogGenericInfo("Success!", Bot.BotName);
|
||||
return;
|
||||
if (!setCookieValue.Contains("steamparental=")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
string setCookie = setCookieValue.Substring(setCookieValue.IndexOf("steamparental=", StringComparison.Ordinal) + 14);
|
||||
|
||||
int index = setCookie.IndexOf(';');
|
||||
if (index > 0) {
|
||||
setCookie = setCookie.Substring(0, index);
|
||||
}
|
||||
|
||||
Cookie["steamparental"] = setCookie;
|
||||
Logging.LogGenericInfo("Success!", Bot.BotName);
|
||||
return;
|
||||
}
|
||||
|
||||
Logging.LogGenericWarning("Failed to unlock parental account!", Bot.BotName);
|
||||
|
||||
@@ -66,14 +66,6 @@ namespace ArchiSteamFarm {
|
||||
private bool LoggedInElsewhere = false;
|
||||
private string AuthCode, TwoFactorAuth;
|
||||
|
||||
internal static string GetAnyBotName() {
|
||||
foreach (string botName in Bots.Keys) {
|
||||
return botName;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static async Task RefreshCMs(uint cellID) {
|
||||
bool initialized = false;
|
||||
for (byte i = 0; i < 3 && !initialized; i++) {
|
||||
@@ -331,7 +323,7 @@ namespace ArchiSteamFarm {
|
||||
return ResponseRejoinChat();
|
||||
case "!restart":
|
||||
Program.Restart();
|
||||
return "Done";
|
||||
return null;
|
||||
case "!status":
|
||||
return ResponseStatus();
|
||||
case "!statusall":
|
||||
@@ -902,17 +894,16 @@ namespace ArchiSteamFarm {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: I really need something better
|
||||
if (steamID < 110300000000000000) {
|
||||
SteamFriends.SendChatMessage(steamID, EChatEntryType.ChatMsg, message);
|
||||
} else {
|
||||
if (new SteamID(steamID).IsChatAccount) {
|
||||
SteamFriends.SendChatRoomMessage(steamID, EChatEntryType.ChatMsg, message);
|
||||
} else {
|
||||
SteamFriends.SendChatMessage(steamID, EChatEntryType.ChatMsg, message);
|
||||
}
|
||||
}
|
||||
|
||||
private bool LinkMobileAuthenticator() {
|
||||
private void LinkMobileAuthenticator() {
|
||||
if (BotDatabase.SteamGuardAccount != null) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
Logging.LogGenericInfo("Linking new ASF MobileAuthenticator...", BotName);
|
||||
@@ -925,7 +916,7 @@ namespace ArchiSteamFarm {
|
||||
break;
|
||||
default:
|
||||
Logging.LogGenericError("Unhandled situation: " + loginResult, BotName);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -939,7 +930,7 @@ namespace ArchiSteamFarm {
|
||||
break;
|
||||
default:
|
||||
Logging.LogGenericError("Unhandled situation: " + linkResult, BotName);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -949,12 +940,11 @@ namespace ArchiSteamFarm {
|
||||
if (finalizeResult != AuthenticatorLinker.FinalizeResult.Success) {
|
||||
Logging.LogGenericError("Unhandled situation: " + finalizeResult, BotName);
|
||||
DelinkMobileAuthenticator();
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
Logging.LogGenericInfo("Successfully linked ASF as new mobile authenticator for this account!", BotName);
|
||||
Program.GetUserInput(BotName, Program.EUserInputType.RevocationCode, BotDatabase.SteamGuardAccount.RevocationCode);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool DelinkMobileAuthenticator() {
|
||||
|
||||
@@ -27,6 +27,7 @@ using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -78,11 +79,7 @@ namespace ArchiSteamFarm {
|
||||
return 0;
|
||||
}
|
||||
|
||||
foreach (uint appID in gamesToFarm.Keys) {
|
||||
return appID;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return gamesToFarm.Keys.FirstOrDefault();
|
||||
}
|
||||
|
||||
internal async Task<bool> SwitchToManualMode(bool manualMode) {
|
||||
@@ -109,7 +106,6 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
float maxHour = 0;
|
||||
|
||||
foreach (float hour in appIDs.Values) {
|
||||
if (hour > maxHour) {
|
||||
maxHour = hour;
|
||||
@@ -326,7 +322,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
foreach (HtmlNode htmlNode in htmlNodeCollection) {
|
||||
string steamLink = htmlNode.GetAttributeValue("href", null);
|
||||
if (steamLink == null) {
|
||||
if (string.IsNullOrEmpty(steamLink)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace ArchiSteamFarm {
|
||||
internal bool AutoUpdates { get; private set; } = true;
|
||||
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
internal EUpdateChannel UpdateChannel { get; private set; } = GlobalConfig.EUpdateChannel.Stable;
|
||||
internal EUpdateChannel UpdateChannel { get; private set; } = EUpdateChannel.Stable;
|
||||
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
internal byte MaxFarmingTime { get; private set; } = 10;
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
*/
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using SteamAuth;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace ArchiSteamFarm {
|
||||
return;
|
||||
}
|
||||
|
||||
GitHub.ReleaseResponse releaseResponse = null;
|
||||
GitHub.ReleaseResponse releaseResponse;
|
||||
if (GlobalConfig.UpdateChannel == GlobalConfig.EUpdateChannel.Stable) {
|
||||
try {
|
||||
releaseResponse = JsonConvert.DeserializeObject<GitHub.ReleaseResponse>(response);
|
||||
@@ -143,8 +143,8 @@ namespace ArchiSteamFarm {
|
||||
|
||||
Logging.LogGenericInfo("Local version: " + Version + " | Remote version: " + releaseResponse.Tag);
|
||||
|
||||
if (Version.CompareTo(releaseResponse.Tag) >= 0) { // If local version is the same or newer than remote version
|
||||
// Set up a timer that will automatically update ASF on as-needed basis
|
||||
if (string.Compare(Version, releaseResponse.Tag, StringComparison.Ordinal) >= 0) { // If local version is the same or newer than remote version
|
||||
// Set up a timer that will automatically update ASF on as-needed basis
|
||||
if (GlobalConfig.AutoUpdates && AutoUpdatesTimer == null) {
|
||||
Logging.LogGenericInfo("ASF will automatically check for new versions every 24 hours");
|
||||
AutoUpdatesTimer = new Timer(
|
||||
@@ -314,7 +314,7 @@ namespace ArchiSteamFarm {
|
||||
ConsoleIsBusy = false;
|
||||
}
|
||||
|
||||
return result.Trim(); // Get rid of all whitespace characters
|
||||
return string.IsNullOrEmpty(result) ? null : result.Trim();
|
||||
}
|
||||
|
||||
internal static void OnBotShutdown() {
|
||||
|
||||
@@ -27,7 +27,6 @@ using Newtonsoft.Json;
|
||||
namespace ArchiSteamFarm {
|
||||
internal sealed class SteamItem {
|
||||
// REF: https://developer.valvesoftware.com/wiki/Steam_Web_API/IEconService#CEcon_Asset
|
||||
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
internal string appid { get; set; }
|
||||
|
||||
|
||||
@@ -50,15 +50,17 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
internal async void CheckTrades() {
|
||||
if (ParsingTasks < 2) {
|
||||
ParsingTasks++;
|
||||
|
||||
await Semaphore.WaitAsync().ConfigureAwait(false);
|
||||
await ParseActiveTrades().ConfigureAwait(false);
|
||||
Semaphore.Release();
|
||||
|
||||
ParsingTasks--;
|
||||
if (ParsingTasks >= 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
ParsingTasks++;
|
||||
|
||||
await Semaphore.WaitAsync().ConfigureAwait(false);
|
||||
await ParseActiveTrades().ConfigureAwait(false);
|
||||
Semaphore.Release();
|
||||
|
||||
ParsingTasks--;
|
||||
}
|
||||
|
||||
private async Task ParseActiveTrades() {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Channels;
|
||||
|
||||
@@ -100,7 +101,7 @@ namespace ArchiSteamFarm {
|
||||
if (args.Length > 1) { // If we have args[1] provided, use given botName
|
||||
botName = args[1];
|
||||
} else { // If not, just pick first one
|
||||
botName = Bot.GetAnyBotName();
|
||||
botName = Bot.Bots.Keys.FirstOrDefault();
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(botName)) {
|
||||
|
||||
Reference in New Issue
Block a user