mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-18 15:30:30 +00:00
Code review
This commit is contained in:
@@ -149,6 +149,7 @@ namespace ArchiSteamFarm {
|
|||||||
KeyValue receiptInfo = new KeyValue();
|
KeyValue receiptInfo = new KeyValue();
|
||||||
using (MemoryStream ms = new MemoryStream(msg.purchase_receipt_info)) {
|
using (MemoryStream ms = new MemoryStream(msg.purchase_receipt_info)) {
|
||||||
if (!receiptInfo.TryReadAsBinary(ms)) {
|
if (!receiptInfo.TryReadAsBinary(ms)) {
|
||||||
|
Logging.LogNullError(nameof(ms));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +203,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void PlayGames(ICollection<uint> gameIDs) {
|
internal void PlayGames(ICollection<uint> gameIDs) {
|
||||||
if ((gameIDs == null) || !Client.IsConnected) {
|
if (gameIDs == null) {
|
||||||
|
Logging.LogNullError(nameof(gameIDs), Bot.BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Client.IsConnected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +223,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<PurchaseResponseCallback> RedeemKey(string key) {
|
internal async Task<PurchaseResponseCallback> RedeemKey(string key) {
|
||||||
if (string.IsNullOrEmpty(key) || !Client.IsConnected) {
|
if (string.IsNullOrEmpty(key)) {
|
||||||
|
Logging.LogNullError(nameof(key), Bot.BotName);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Client.IsConnected) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,6 +292,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
public override void HandleMsg(IPacketMsg packetMsg) {
|
public override void HandleMsg(IPacketMsg packetMsg) {
|
||||||
if (packetMsg == null) {
|
if (packetMsg == null) {
|
||||||
|
Logging.LogNullError(nameof(packetMsg), Bot.BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,6 +317,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private void HandleFSOfflineMessageNotification(IPacketMsg packetMsg) {
|
private void HandleFSOfflineMessageNotification(IPacketMsg packetMsg) {
|
||||||
if (packetMsg == null) {
|
if (packetMsg == null) {
|
||||||
|
Logging.LogNullError(nameof(packetMsg), Bot.BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,6 +327,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private void HandleItemAnnouncements(IPacketMsg packetMsg) {
|
private void HandleItemAnnouncements(IPacketMsg packetMsg) {
|
||||||
if (packetMsg == null) {
|
if (packetMsg == null) {
|
||||||
|
Logging.LogNullError(nameof(packetMsg), Bot.BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,6 +337,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private void HandlePlayingSessionState(IPacketMsg packetMsg) {
|
private void HandlePlayingSessionState(IPacketMsg packetMsg) {
|
||||||
if (packetMsg == null) {
|
if (packetMsg == null) {
|
||||||
|
Logging.LogNullError(nameof(packetMsg), Bot.BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,6 +347,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private void HandlePurchaseResponse(IPacketMsg packetMsg) {
|
private void HandlePurchaseResponse(IPacketMsg packetMsg) {
|
||||||
if (packetMsg == null) {
|
if (packetMsg == null) {
|
||||||
|
Logging.LogNullError(nameof(packetMsg), Bot.BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,6 +357,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private void HandleUserNotifications(IPacketMsg packetMsg) {
|
private void HandleUserNotifications(IPacketMsg packetMsg) {
|
||||||
if (packetMsg == null) {
|
if (packetMsg == null) {
|
||||||
|
Logging.LogNullError(nameof(packetMsg), Bot.BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ using HtmlAgilityPack;
|
|||||||
using SteamKit2;
|
using SteamKit2;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -55,20 +56,28 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static uint GetAppIDFromMarketHashName(string hashName) {
|
private static uint GetAppIDFromMarketHashName(string hashName) {
|
||||||
if (string.IsNullOrEmpty(hashName)) {
|
if (string.IsNullOrEmpty(hashName)) {
|
||||||
|
Logging.LogNullError(nameof(hashName));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = hashName.IndexOf('-');
|
int index = hashName.IndexOf('-');
|
||||||
if (index < 1) {
|
if (index < 1) {
|
||||||
|
Logging.LogNullError(nameof(index));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint appID;
|
uint appID;
|
||||||
return !uint.TryParse(hashName.Substring(0, index), out appID) ? 0 : appID;
|
if (uint.TryParse(hashName.Substring(0, index), out appID)) {
|
||||||
|
return appID;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.LogNullError(nameof(appID));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Steam.Item.EType GetItemType(string name) {
|
private static Steam.Item.EType GetItemType(string name) {
|
||||||
if (string.IsNullOrEmpty(name)) {
|
if (string.IsNullOrEmpty(name)) {
|
||||||
|
Logging.LogNullError(nameof(name));
|
||||||
return Steam.Item.EType.Unknown;
|
return Steam.Item.EType.Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,6 +119,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal bool Init(SteamClient steamClient, string webAPIUserNonce, string parentalPin) {
|
internal bool Init(SteamClient steamClient, string webAPIUserNonce, string parentalPin) {
|
||||||
if ((steamClient == null) || string.IsNullOrEmpty(webAPIUserNonce)) {
|
if ((steamClient == null) || string.IsNullOrEmpty(webAPIUserNonce)) {
|
||||||
|
Logging.LogNullError(nameof(steamClient) + " || " + nameof(webAPIUserNonce), Bot.BotName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,6 +168,7 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (authResult == null) {
|
if (authResult == null) {
|
||||||
|
Logging.LogNullError(nameof(authResult), Bot.BotName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,6 +192,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal async Task<bool> AcceptGift(ulong gid) {
|
internal async Task<bool> AcceptGift(ulong gid) {
|
||||||
if (gid == 0) {
|
if (gid == 0) {
|
||||||
|
Logging.LogNullError(nameof(gid), Bot.BotName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +202,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
string sessionID = WebBrowser.CookieContainer.GetCookieValue(SteamCommunityURL, "sessionid");
|
string sessionID = WebBrowser.CookieContainer.GetCookieValue(SteamCommunityURL, "sessionid");
|
||||||
if (string.IsNullOrEmpty(sessionID)) {
|
if (string.IsNullOrEmpty(sessionID)) {
|
||||||
Logging.LogNullError("sessionID");
|
Logging.LogNullError(nameof(sessionID), Bot.BotName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,21 +211,12 @@ namespace ArchiSteamFarm {
|
|||||||
{ "sessionid", sessionID }
|
{ "sessionid", sessionID }
|
||||||
};
|
};
|
||||||
|
|
||||||
bool result = false;
|
return await WebBrowser.UrlPostRetry(request, data).ConfigureAwait(false);
|
||||||
for (byte i = 0; (i < WebBrowser.MaxRetries) && !result; i++) {
|
|
||||||
result = await WebBrowser.UrlPost(request, data).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries", Bot.BotName);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<bool> JoinGroup(ulong groupID) {
|
internal async Task<bool> JoinGroup(ulong groupID) {
|
||||||
if (groupID == 0) {
|
if (groupID == 0) {
|
||||||
|
Logging.LogNullError(nameof(groupID), Bot.BotName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,7 +226,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
string sessionID = WebBrowser.CookieContainer.GetCookieValue(SteamCommunityURL, "sessionid");
|
string sessionID = WebBrowser.CookieContainer.GetCookieValue(SteamCommunityURL, "sessionid");
|
||||||
if (string.IsNullOrEmpty(sessionID)) {
|
if (string.IsNullOrEmpty(sessionID)) {
|
||||||
Logging.LogNullError("sessionID");
|
Logging.LogNullError(nameof(sessionID), Bot.BotName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,17 +236,7 @@ namespace ArchiSteamFarm {
|
|||||||
{ "action", "join" }
|
{ "action", "join" }
|
||||||
};
|
};
|
||||||
|
|
||||||
bool result = false;
|
return await WebBrowser.UrlPostRetry(request, data).ConfigureAwait(false);
|
||||||
for (byte i = 0; (i < WebBrowser.MaxRetries) && !result; i++) {
|
|
||||||
result = await WebBrowser.UrlPost(request, data).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries", Bot.BotName);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<Dictionary<uint, string>> GetOwnedGames() {
|
internal async Task<Dictionary<uint, string>> GetOwnedGames() {
|
||||||
@@ -253,13 +246,8 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
string request = SteamCommunityURL + "/my/games/?xml=1";
|
string request = SteamCommunityURL + "/my/games/?xml=1";
|
||||||
|
|
||||||
XmlDocument response = null;
|
XmlDocument response = await WebBrowser.UrlGetToXMLRetry(request).ConfigureAwait(false);
|
||||||
for (byte i = 0; (i < WebBrowser.MaxRetries) && (response == null); i++) {
|
|
||||||
response = await WebBrowser.UrlGetToXML(request).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries", Bot.BotName);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,16 +260,19 @@ namespace ArchiSteamFarm {
|
|||||||
foreach (XmlNode xmlNode in xmlNodeList) {
|
foreach (XmlNode xmlNode in xmlNodeList) {
|
||||||
XmlNode appNode = xmlNode.SelectSingleNode("appID");
|
XmlNode appNode = xmlNode.SelectSingleNode("appID");
|
||||||
if (appNode == null) {
|
if (appNode == null) {
|
||||||
|
Logging.LogNullError(nameof(appNode), Bot.BotName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint appID;
|
uint appID;
|
||||||
if (!uint.TryParse(appNode.InnerText, out appID)) {
|
if (!uint.TryParse(appNode.InnerText, out appID)) {
|
||||||
|
Logging.LogNullError(nameof(appID), Bot.BotName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlNode nameNode = xmlNode.SelectSingleNode("name");
|
XmlNode nameNode = xmlNode.SelectSingleNode("name");
|
||||||
if (nameNode == null) {
|
if (nameNode == null) {
|
||||||
|
Logging.LogNullError(nameof(nameNode), Bot.BotName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,6 +284,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal Dictionary<uint, string> GetOwnedGames(ulong steamID) {
|
internal Dictionary<uint, string> GetOwnedGames(ulong steamID) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(Bot.BotConfig.SteamApiKey)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(Bot.BotConfig.SteamApiKey)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(Bot.BotConfig.SteamApiKey), Bot.BotName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,7 +300,7 @@ namespace ArchiSteamFarm {
|
|||||||
secure: !Program.GlobalConfig.ForceHttp
|
secure: !Program.GlobalConfig.ForceHttp
|
||||||
);
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logging.LogGenericException(e);
|
Logging.LogGenericException(e, Bot.BotName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -322,6 +314,7 @@ namespace ArchiSteamFarm {
|
|||||||
foreach (KeyValue game in response["games"].Children) {
|
foreach (KeyValue game in response["games"].Children) {
|
||||||
uint appID = (uint) game["appid"].AsUnsignedLong();
|
uint appID = (uint) game["appid"].AsUnsignedLong();
|
||||||
if (appID == 0) {
|
if (appID == 0) {
|
||||||
|
Logging.LogNullError(nameof(appID));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,6 +326,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal HashSet<Steam.TradeOffer> GetTradeOffers() {
|
internal HashSet<Steam.TradeOffer> GetTradeOffers() {
|
||||||
if (string.IsNullOrEmpty(Bot.BotConfig.SteamApiKey)) {
|
if (string.IsNullOrEmpty(Bot.BotConfig.SteamApiKey)) {
|
||||||
|
Logging.LogNullError(nameof(Bot.BotConfig.SteamApiKey), Bot.BotName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,6 +357,7 @@ namespace ArchiSteamFarm {
|
|||||||
foreach (KeyValue description in response["descriptions"].Children) {
|
foreach (KeyValue description in response["descriptions"].Children) {
|
||||||
ulong classID = description["classid"].AsUnsignedLong();
|
ulong classID = description["classid"].AsUnsignedLong();
|
||||||
if (classID == 0) {
|
if (classID == 0) {
|
||||||
|
Logging.LogNullError(nameof(classID), Bot.BotName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,6 +442,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal async Task<bool> AcceptTradeOffer(ulong tradeID) {
|
internal async Task<bool> AcceptTradeOffer(ulong tradeID) {
|
||||||
if (tradeID == 0) {
|
if (tradeID == 0) {
|
||||||
|
Logging.LogNullError(nameof(tradeID), Bot.BotName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,7 +452,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
string sessionID = WebBrowser.CookieContainer.GetCookieValue(SteamCommunityURL, "sessionid");
|
string sessionID = WebBrowser.CookieContainer.GetCookieValue(SteamCommunityURL, "sessionid");
|
||||||
if (string.IsNullOrEmpty(sessionID)) {
|
if (string.IsNullOrEmpty(sessionID)) {
|
||||||
Logging.LogNullError("sessionID");
|
Logging.LogNullError(nameof(sessionID), Bot.BotName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,17 +464,7 @@ namespace ArchiSteamFarm {
|
|||||||
{ "tradeofferid", tradeID.ToString() }
|
{ "tradeofferid", tradeID.ToString() }
|
||||||
};
|
};
|
||||||
|
|
||||||
bool result = false;
|
return await WebBrowser.UrlPostRetry(request, data, referer).ConfigureAwait(false);
|
||||||
for (byte i = 0; (i < WebBrowser.MaxRetries) && !result; i++) {
|
|
||||||
result = await WebBrowser.UrlPost(request, data, referer).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries", Bot.BotName);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<HashSet<Steam.Item>> GetMyTradableInventory() {
|
internal async Task<HashSet<Steam.Item>> GetMyTradableInventory() {
|
||||||
@@ -492,40 +478,39 @@ namespace ArchiSteamFarm {
|
|||||||
while (true) {
|
while (true) {
|
||||||
string request = SteamCommunityURL + "/my/inventory/json/" + Steam.Item.SteamAppID + "/" + Steam.Item.SteamContextID + "?trading=1&start=" + nextPage;
|
string request = SteamCommunityURL + "/my/inventory/json/" + Steam.Item.SteamAppID + "/" + Steam.Item.SteamContextID + "?trading=1&start=" + nextPage;
|
||||||
|
|
||||||
JObject jObject = null;
|
JObject jObject = await WebBrowser.UrlGetToJObjectRetry(request).ConfigureAwait(false);
|
||||||
for (byte i = 0; (i < WebBrowser.MaxRetries) && (jObject == null); i++) {
|
|
||||||
jObject = await WebBrowser.UrlGetToJObject(request).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jObject == null) {
|
if (jObject == null) {
|
||||||
Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries", Bot.BotName);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<JToken> descriptions = jObject.SelectTokens("$.rgDescriptions.*");
|
IEnumerable<JToken> descriptions = jObject.SelectTokens("$.rgDescriptions.*");
|
||||||
if (descriptions == null) {
|
if (descriptions == null) {
|
||||||
return null;
|
return null; // OK, empty inventory
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<Tuple<ulong, ulong>, Tuple<uint, Steam.Item.EType>> descriptionMap = new Dictionary<Tuple<ulong, ulong>, Tuple<uint, Steam.Item.EType>>();
|
Dictionary<Tuple<ulong, ulong>, Tuple<uint, Steam.Item.EType>> descriptionMap = new Dictionary<Tuple<ulong, ulong>, Tuple<uint, Steam.Item.EType>>();
|
||||||
foreach (JToken description in descriptions) {
|
foreach (JToken description in descriptions) {
|
||||||
string classIDString = description["classid"].ToString();
|
string classIDString = description["classid"].ToString();
|
||||||
if (string.IsNullOrEmpty(classIDString)) {
|
if (string.IsNullOrEmpty(classIDString)) {
|
||||||
|
Logging.LogNullError(nameof(classIDString), Bot.BotName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ulong classID;
|
ulong classID;
|
||||||
if (!ulong.TryParse(classIDString, out classID) || (classID == 0)) {
|
if (!ulong.TryParse(classIDString, out classID) || (classID == 0)) {
|
||||||
|
Logging.LogNullError(nameof(classID), Bot.BotName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
string instanceIDString = description["instanceid"].ToString();
|
string instanceIDString = description["instanceid"].ToString();
|
||||||
if (string.IsNullOrEmpty(instanceIDString)) {
|
if (string.IsNullOrEmpty(instanceIDString)) {
|
||||||
|
Logging.LogNullError(nameof(instanceIDString), Bot.BotName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ulong instanceID;
|
ulong instanceID;
|
||||||
if (!ulong.TryParse(instanceIDString, out instanceID)) {
|
if (!ulong.TryParse(instanceIDString, out instanceID)) {
|
||||||
|
Logging.LogNullError(nameof(instanceID), Bot.BotName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,6 +537,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
IEnumerable<JToken> items = jObject.SelectTokens("$.rgInventory.*");
|
IEnumerable<JToken> items = jObject.SelectTokens("$.rgInventory.*");
|
||||||
if (items == null) {
|
if (items == null) {
|
||||||
|
Logging.LogNullError(nameof(items), Bot.BotName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -567,6 +553,7 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (steamItem == null) {
|
if (steamItem == null) {
|
||||||
|
Logging.LogNullError(nameof(steamItem), Bot.BotName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -583,12 +570,15 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
bool more;
|
bool more;
|
||||||
if (!bool.TryParse(jObject["more"].ToString(), out more) || !more) {
|
if (!bool.TryParse(jObject["more"].ToString(), out more) || !more) {
|
||||||
break;
|
break; // OK, last page
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ushort.TryParse(jObject["more_start"].ToString(), out nextPage)) {
|
if (ushort.TryParse(jObject["more_start"].ToString(), out nextPage)) {
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logging.LogNullError(nameof(nextPage), Bot.BotName);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -596,6 +586,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal async Task<bool> SendTradeOffer(HashSet<Steam.Item> inventory, ulong partnerID, string token = null) {
|
internal async Task<bool> SendTradeOffer(HashSet<Steam.Item> inventory, ulong partnerID, string token = null) {
|
||||||
if ((inventory == null) || (inventory.Count == 0) || (partnerID == 0)) {
|
if ((inventory == null) || (inventory.Count == 0) || (partnerID == 0)) {
|
||||||
|
Logging.LogNullError(nameof(inventory) + " || " + nameof(inventory.Count) + " || " + nameof(partnerID), Bot.BotName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -605,7 +596,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
string sessionID = WebBrowser.CookieContainer.GetCookieValue(SteamCommunityURL, "sessionid");
|
string sessionID = WebBrowser.CookieContainer.GetCookieValue(SteamCommunityURL, "sessionid");
|
||||||
if (string.IsNullOrEmpty(sessionID)) {
|
if (string.IsNullOrEmpty(sessionID)) {
|
||||||
Logging.LogNullError("sessionID");
|
Logging.LogNullError(nameof(sessionID), Bot.BotName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -636,27 +627,17 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
string referer = SteamCommunityURL + "/tradeoffer/new";
|
string referer = SteamCommunityURL + "/tradeoffer/new";
|
||||||
string request = referer + "/send";
|
string request = referer + "/send";
|
||||||
foreach (Steam.TradeOfferRequest trade in trades) {
|
foreach (Dictionary<string, string> data in trades.Select(trade => new Dictionary<string, string>(6) {
|
||||||
Dictionary<string, string> data = new Dictionary<string, string>(6) {
|
{ "sessionid", sessionID },
|
||||||
{ "sessionid", sessionID },
|
{ "serverid", "1" },
|
||||||
{ "serverid", "1" },
|
{ "partner", partnerID.ToString() },
|
||||||
{ "partner", partnerID.ToString() },
|
{ "tradeoffermessage", "Sent by ASF" },
|
||||||
{ "tradeoffermessage", "Sent by ASF" },
|
{ "json_tradeoffer", JsonConvert.SerializeObject(trade) },
|
||||||
{ "json_tradeoffer", JsonConvert.SerializeObject(trade) },
|
{ "trade_offer_create_params", string.IsNullOrEmpty(token) ? "" : $"{{\"trade_offer_access_token\":\"{token}\"}}" }
|
||||||
{ "trade_offer_create_params", string.IsNullOrEmpty(token) ? "" : $"{{\"trade_offer_access_token\":\"{token}\"}}" }
|
})) {
|
||||||
};
|
if (!await WebBrowser.UrlPostRetry(request, data, referer).ConfigureAwait(false)) {
|
||||||
|
return false;
|
||||||
bool result = false;
|
|
||||||
for (byte i = 0; (i < WebBrowser.MaxRetries) && !result; i++) {
|
|
||||||
result = await WebBrowser.UrlPost(request, data, referer).ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries", Bot.BotName);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -664,6 +645,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal async Task<HtmlDocument> GetBadgePage(byte page) {
|
internal async Task<HtmlDocument> GetBadgePage(byte page) {
|
||||||
if (page == 0) {
|
if (page == 0) {
|
||||||
|
Logging.LogNullError(nameof(page), Bot.BotName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -673,21 +655,12 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
string request = SteamCommunityURL + "/my/badges?p=" + page;
|
string request = SteamCommunityURL + "/my/badges?p=" + page;
|
||||||
|
|
||||||
HtmlDocument htmlDocument = null;
|
return await WebBrowser.UrlGetToHtmlDocumentRetry(request).ConfigureAwait(false);
|
||||||
for (byte i = 0; (i < WebBrowser.MaxRetries) && (htmlDocument == null); i++) {
|
|
||||||
htmlDocument = await WebBrowser.UrlGetToHtmlDocument(request).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (htmlDocument != null) {
|
|
||||||
return htmlDocument;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries", Bot.BotName);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<HtmlDocument> GetGameCardsPage(ulong appID) {
|
internal async Task<HtmlDocument> GetGameCardsPage(ulong appID) {
|
||||||
if (appID == 0) {
|
if (appID == 0) {
|
||||||
|
Logging.LogNullError(nameof(appID), Bot.BotName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -697,17 +670,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
string request = SteamCommunityURL + "/my/gamecards/" + appID;
|
string request = SteamCommunityURL + "/my/gamecards/" + appID;
|
||||||
|
|
||||||
HtmlDocument htmlDocument = null;
|
return await WebBrowser.UrlGetToHtmlDocumentRetry(request).ConfigureAwait(false);
|
||||||
for (byte i = 0; (i < WebBrowser.MaxRetries) && (htmlDocument == null); i++) {
|
|
||||||
htmlDocument = await WebBrowser.UrlGetToHtmlDocument(request).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (htmlDocument != null) {
|
|
||||||
return htmlDocument;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries", Bot.BotName);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<bool> MarkInventory() {
|
internal async Task<bool> MarkInventory() {
|
||||||
@@ -717,33 +680,18 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
string request = SteamCommunityURL + "/my/inventory";
|
string request = SteamCommunityURL + "/my/inventory";
|
||||||
|
|
||||||
bool result = false;
|
return await WebBrowser.UrlHeadRetry(request).ConfigureAwait(false);
|
||||||
for (byte i = 0; (i < WebBrowser.MaxRetries) && !result; i++) {
|
|
||||||
result = await WebBrowser.UrlHead(request).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries", Bot.BotName);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool?> IsLoggedIn() {
|
private async Task<bool?> IsLoggedIn() {
|
||||||
string request = SteamCommunityURL + "/my/profile";
|
string request = SteamCommunityURL + "/my/profile";
|
||||||
|
|
||||||
Uri uri = null;
|
Uri uri = await WebBrowser.UrlHeadToUriRetry(request).ConfigureAwait(false);
|
||||||
for (byte i = 0; (i < WebBrowser.MaxRetries) && (uri == null); i++) {
|
if (uri == null) {
|
||||||
uri = await WebBrowser.UrlHeadToUri(request).ConfigureAwait(false);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uri != null) {
|
return !uri.AbsolutePath.StartsWith("/login", StringComparison.Ordinal);
|
||||||
return !uri.AbsolutePath.StartsWith("/login", StringComparison.Ordinal);
|
|
||||||
}
|
|
||||||
|
|
||||||
Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries", Bot.BotName);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> RefreshSessionIfNeeded() {
|
private async Task<bool> RefreshSessionIfNeeded() {
|
||||||
@@ -774,7 +722,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> UnlockParentalAccount(string parentalPin) {
|
private async Task<bool> UnlockParentalAccount(string parentalPin) {
|
||||||
if (string.IsNullOrEmpty(parentalPin) || parentalPin.Equals("0")) {
|
if (string.IsNullOrEmpty(parentalPin)) {
|
||||||
|
Logging.LogNullError(nameof(parentalPin), Bot.BotName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parentalPin.Equals("0")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -785,13 +738,9 @@ namespace ArchiSteamFarm {
|
|||||||
{ "pin", parentalPin }
|
{ "pin", parentalPin }
|
||||||
};
|
};
|
||||||
|
|
||||||
bool result = false;
|
bool result = await WebBrowser.UrlPostRetry(request, data, SteamCommunityURL).ConfigureAwait(false);
|
||||||
for (byte i = 0; (i < WebBrowser.MaxRetries) && !result; i++) {
|
|
||||||
result = await WebBrowser.UrlPost(request, data, SteamCommunityURL).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries", Bot.BotName);
|
Logging.LogGenericInfo("Failed!", Bot.BotName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,14 +93,22 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsOwner(ulong steamID) {
|
private static bool IsOwner(ulong steamID) {
|
||||||
if (steamID == 0) {
|
if (steamID != 0) {
|
||||||
return false;
|
return steamID == Program.GlobalConfig.SteamOwnerID;
|
||||||
}
|
}
|
||||||
|
|
||||||
return steamID == Program.GlobalConfig.SteamOwnerID;
|
Logging.LogNullError(nameof(steamID));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsValidCdKey(string key) => !string.IsNullOrEmpty(key) && Regex.IsMatch(key, @"[0-9A-Z]{4,5}-[0-9A-Z]{4,5}-[0-9A-Z]{4,5}-?(?:(?:[0-9A-Z]{4,5}-?)?(?:[0-9A-Z]{4,5}))?");
|
private static bool IsValidCdKey(string key) {
|
||||||
|
if (!string.IsNullOrEmpty(key)) {
|
||||||
|
return Regex.IsMatch(key, @"[0-9A-Z]{4,5}-[0-9A-Z]{4,5}-[0-9A-Z]{4,5}-?(?:(?:[0-9A-Z]{4,5}-?)?(?:[0-9A-Z]{4,5}))?");
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.LogNullError(nameof(key));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static async Task LimitLoginRequestsAsync() {
|
private static async Task LimitLoginRequestsAsync() {
|
||||||
await LoginSemaphore.WaitAsync().ConfigureAwait(false);
|
await LoginSemaphore.WaitAsync().ConfigureAwait(false);
|
||||||
@@ -126,6 +134,7 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!BotConfig.Enabled) {
|
if (!BotConfig.Enabled) {
|
||||||
|
Logging.LogGenericInfo("Not starting this instance because it's disabled in config file", botName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,6 +336,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal async Task<string> Response(ulong steamID, string message) {
|
internal async Task<string> Response(ulong steamID, string message) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(message)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(message)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(message), BotName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,11 +459,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private bool IsMaster(ulong steamID) {
|
private bool IsMaster(ulong steamID) {
|
||||||
if (steamID == 0) {
|
if (steamID != 0) {
|
||||||
return false;
|
return (steamID == BotConfig.SteamMasterID) || IsOwner(steamID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (steamID == BotConfig.SteamMasterID) || IsOwner(steamID);
|
Logging.LogNullError(nameof(steamID), BotName);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ImportAuthenticator(string maFilePath) {
|
private void ImportAuthenticator(string maFilePath) {
|
||||||
@@ -462,6 +473,7 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Logging.LogGenericInfo("Converting SDA .maFile into ASF format...", BotName);
|
Logging.LogGenericInfo("Converting SDA .maFile into ASF format...", BotName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BotDatabase.SteamGuardAccount = JsonConvert.DeserializeObject<SteamGuardAccount>(File.ReadAllText(maFilePath));
|
BotDatabase.SteamGuardAccount = JsonConvert.DeserializeObject<SteamGuardAccount>(File.ReadAllText(maFilePath));
|
||||||
File.Delete(maFilePath);
|
File.Delete(maFilePath);
|
||||||
@@ -522,7 +534,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> ResponsePause(ulong steamID) {
|
private async Task<string> ResponsePause(ulong steamID) {
|
||||||
if ((steamID == 0) || !IsMaster(steamID)) {
|
if (steamID == 0) {
|
||||||
|
Logging.LogNullError(nameof(steamID));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsMaster(steamID)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,6 +554,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static async Task<string> ResponsePause(ulong steamID, string botName) {
|
private static async Task<string> ResponsePause(ulong steamID, string botName) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(botName));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,7 +571,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string ResponseStatus(ulong steamID) {
|
private string ResponseStatus(ulong steamID) {
|
||||||
if ((steamID == 0) || !IsMaster(steamID)) {
|
if (steamID == 0) {
|
||||||
|
Logging.LogNullError(nameof(steamID));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsMaster(steamID)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,6 +601,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static string ResponseStatus(ulong steamID, string botName) {
|
private static string ResponseStatus(ulong steamID, string botName) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(botName));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -595,6 +619,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static string ResponseStatusAll(ulong steamID) {
|
private static string ResponseStatusAll(ulong steamID) {
|
||||||
if (steamID == 0) {
|
if (steamID == 0) {
|
||||||
|
Logging.LogNullError(nameof(steamID));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -617,7 +642,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> ResponseSendTrade(ulong steamID) {
|
private async Task<string> ResponseSendTrade(ulong steamID) {
|
||||||
if ((steamID == 0) || !IsMaster(steamID)) {
|
if (steamID == 0) {
|
||||||
|
Logging.LogNullError(nameof(steamID));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsMaster(steamID)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -650,6 +680,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static async Task<string> ResponseSendTrade(ulong steamID, string botName) {
|
private static async Task<string> ResponseSendTrade(ulong steamID, string botName) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(botName));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -666,7 +697,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string Response2FA(ulong steamID) {
|
private string Response2FA(ulong steamID) {
|
||||||
if ((steamID == 0) || !IsMaster(steamID)) {
|
if (steamID == 0) {
|
||||||
|
Logging.LogNullError(nameof(steamID));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsMaster(steamID)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -680,6 +716,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static string Response2FA(ulong steamID, string botName) {
|
private static string Response2FA(ulong steamID, string botName) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(botName));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,7 +733,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string Response2FAOff(ulong steamID) {
|
private string Response2FAOff(ulong steamID) {
|
||||||
if ((steamID == 0) || !IsMaster(steamID)) {
|
if (steamID == 0) {
|
||||||
|
Logging.LogNullError(nameof(steamID));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsMaster(steamID)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -709,6 +751,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static string Response2FAOff(ulong steamID, string botName) {
|
private static string Response2FAOff(ulong steamID, string botName) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(botName));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -725,7 +768,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> Response2FAConfirm(ulong steamID, bool confirm) {
|
private async Task<string> Response2FAConfirm(ulong steamID, bool confirm) {
|
||||||
if ((steamID == 0) || !IsMaster(steamID)) {
|
if (steamID == 0) {
|
||||||
|
Logging.LogNullError(nameof(steamID));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsMaster(steamID)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -739,6 +787,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static async Task<string> Response2FAConfirm(ulong steamID, string botName, bool confirm) {
|
private static async Task<string> Response2FAConfirm(ulong steamID, string botName, bool confirm) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(botName));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -756,6 +805,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static string ResponseExit(ulong steamID) {
|
private static string ResponseExit(ulong steamID) {
|
||||||
if (steamID == 0) {
|
if (steamID == 0) {
|
||||||
|
Logging.LogNullError(nameof(steamID));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -773,7 +823,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string ResponseFarm(ulong steamID) {
|
private string ResponseFarm(ulong steamID) {
|
||||||
if ((steamID == 0) || !IsMaster(steamID)) {
|
if (steamID == 0) {
|
||||||
|
Logging.LogNullError(nameof(steamID));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsMaster(steamID)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -787,6 +842,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static string ResponseFarm(ulong steamID, string botName) {
|
private static string ResponseFarm(ulong steamID, string botName) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(botName));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -803,7 +859,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string ResponseHelp(ulong steamID) {
|
private string ResponseHelp(ulong steamID) {
|
||||||
if ((steamID == 0) || !IsMaster(steamID)) {
|
if (steamID == 0) {
|
||||||
|
Logging.LogNullError(nameof(steamID));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsMaster(steamID)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -811,7 +872,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> ResponseRedeem(ulong steamID, string message, bool validate) {
|
private async Task<string> ResponseRedeem(ulong steamID, string message, bool validate) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(message) || !IsMaster(steamID)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(message)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(message));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsMaster(steamID)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -904,6 +970,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static async Task<string> ResponseRedeem(ulong steamID, string botName, string message, bool validate) {
|
private static async Task<string> ResponseRedeem(ulong steamID, string botName, string message, bool validate) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(message)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(message)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(botName) + " || " + nameof(message));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -920,6 +987,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static string ResponseRejoinChat(ulong steamID) {
|
private static string ResponseRejoinChat(ulong steamID) {
|
||||||
if (steamID == 0) {
|
if (steamID == 0) {
|
||||||
|
Logging.LogNullError(nameof(steamID));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -936,6 +1004,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static string ResponseRestart(ulong steamID) {
|
private static string ResponseRestart(ulong steamID) {
|
||||||
if (steamID == 0) {
|
if (steamID == 0) {
|
||||||
|
Logging.LogNullError(nameof(steamID));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -953,7 +1022,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> ResponseAddLicense(ulong steamID, ICollection<uint> gameIDs) {
|
private async Task<string> ResponseAddLicense(ulong steamID, ICollection<uint> gameIDs) {
|
||||||
if ((steamID == 0) || (gameIDs == null) || (gameIDs.Count == 0) || !SteamClient.IsConnected || !IsMaster(steamID)) {
|
if ((steamID == 0) || (gameIDs == null) || (gameIDs.Count == 0)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(gameIDs) + " || " + nameof(gameIDs.Count));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SteamClient.IsConnected || !IsMaster(steamID)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -972,6 +1046,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static async Task<string> ResponseAddLicense(ulong steamID, string botName, string games) {
|
private static async Task<string> ResponseAddLicense(ulong steamID, string botName, string games) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(games)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(games)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(botName) + " || " + nameof(games));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1004,7 +1079,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> ResponseOwns(ulong steamID, string query) {
|
private async Task<string> ResponseOwns(ulong steamID, string query) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(query) || !IsMaster(steamID)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(query)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(query));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsMaster(steamID)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1051,6 +1131,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static async Task<string> ResponseOwns(ulong steamID, string botName, string query) {
|
private static async Task<string> ResponseOwns(ulong steamID, string botName, string query) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(query)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(query)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(botName) + " || " + nameof(query));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1067,7 +1148,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> ResponsePlay(ulong steamID, HashSet<uint> gameIDs) {
|
private async Task<string> ResponsePlay(ulong steamID, HashSet<uint> gameIDs) {
|
||||||
if ((steamID == 0) || (gameIDs == null) || (gameIDs.Count == 0) || !IsMaster(steamID)) {
|
if ((steamID == 0) || (gameIDs == null) || (gameIDs.Count == 0)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(gameIDs) + " || " + nameof(gameIDs.Count));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsMaster(steamID)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1090,6 +1176,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static async Task<string> ResponsePlay(ulong steamID, string botName, string games) {
|
private static async Task<string> ResponsePlay(ulong steamID, string botName, string games) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(games)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(games)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(botName) + " || " + nameof(games));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1122,7 +1209,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> ResponseStart(ulong steamID) {
|
private async Task<string> ResponseStart(ulong steamID) {
|
||||||
if ((steamID == 0) || !IsMaster(steamID)) {
|
if (steamID == 0) {
|
||||||
|
Logging.LogNullError(nameof(steamID));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsMaster(steamID)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1137,6 +1229,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static async Task<string> ResponseStart(ulong steamID, string botName) {
|
private static async Task<string> ResponseStart(ulong steamID, string botName) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(botName));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1153,7 +1246,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string ResponseStop(ulong steamID) {
|
private string ResponseStop(ulong steamID) {
|
||||||
if ((steamID == 0) || !IsMaster(steamID)) {
|
if (steamID == 0) {
|
||||||
|
Logging.LogNullError(nameof(steamID));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsMaster(steamID)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1167,6 +1265,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static string ResponseStop(ulong steamID, string botName) {
|
private static string ResponseStop(ulong steamID, string botName) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(botName)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(botName));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1183,15 +1282,17 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string ResponseUnknown(ulong steamID) {
|
private string ResponseUnknown(ulong steamID) {
|
||||||
if ((steamID == 0) || !IsMaster(steamID)) {
|
if (steamID != 0) {
|
||||||
return null;
|
return !IsMaster(steamID) ? null : "ERROR: Unknown command!";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "ERROR: Unknown command!";
|
Logging.LogNullError(nameof(steamID), BotName);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<string> ResponseUpdate(ulong steamID) {
|
private static async Task<string> ResponseUpdate(ulong steamID) {
|
||||||
if (steamID == 0) {
|
if (steamID == 0) {
|
||||||
|
Logging.LogNullError(nameof(steamID));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1216,6 +1317,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private async Task HandleMessage(ulong chatID, ulong steamID, string message) {
|
private async Task HandleMessage(ulong chatID, ulong steamID, string message) {
|
||||||
if ((chatID == 0) || (steamID == 0) || string.IsNullOrEmpty(message)) {
|
if ((chatID == 0) || (steamID == 0) || string.IsNullOrEmpty(message)) {
|
||||||
|
Logging.LogNullError(nameof(chatID) + " || " + nameof(steamID) + " || " + nameof(message), BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1224,6 +1326,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private void SendMessage(ulong steamID, string message) {
|
private void SendMessage(ulong steamID, string message) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(message)) {
|
if ((steamID == 0) || string.IsNullOrEmpty(message)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(message), BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1235,7 +1338,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void SendMessageToChannel(ulong steamID, string message) {
|
private void SendMessageToChannel(ulong steamID, string message) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(message) || !SteamClient.IsConnected) {
|
if ((steamID == 0) || string.IsNullOrEmpty(message)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(message), BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SteamClient.IsConnected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1246,7 +1354,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void SendMessageToUser(ulong steamID, string message) {
|
private void SendMessageToUser(ulong steamID, string message) {
|
||||||
if ((steamID == 0) || string.IsNullOrEmpty(message) || !SteamClient.IsConnected) {
|
if ((steamID == 0) || string.IsNullOrEmpty(message)) {
|
||||||
|
Logging.LogNullError(nameof(steamID) + " || " + nameof(message), BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SteamClient.IsConnected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1385,6 +1498,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private void OnConnected(SteamClient.ConnectedCallback callback) {
|
private void OnConnected(SteamClient.ConnectedCallback callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
|
Logging.LogNullError(nameof(callback), BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1455,6 +1569,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private async void OnDisconnected(SteamClient.DisconnectedCallback callback) {
|
private async void OnDisconnected(SteamClient.DisconnectedCallback callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
|
Logging.LogNullError(nameof(callback), BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1493,11 +1608,19 @@ namespace ArchiSteamFarm {
|
|||||||
SteamClient.Connect();
|
SteamClient.Connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
[SuppressMessage("ReSharper", "MemberCanBeMadeStatic.Local")]
|
private void OnFreeLicense(SteamApps.FreeLicenseCallback callback) {
|
||||||
private void OnFreeLicense(SteamApps.FreeLicenseCallback callback) { }
|
if (callback == null) {
|
||||||
|
Logging.LogNullError(nameof(callback), BotName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async void OnGuestPassList(SteamApps.GuestPassListCallback callback) {
|
private async void OnGuestPassList(SteamApps.GuestPassListCallback callback) {
|
||||||
if ((callback == null) || (callback.Result != EResult.OK) || (callback.CountGuestPassesToRedeem == 0) || (callback.GuestPasses.Count == 0) || !BotConfig.AcceptGifts) {
|
if ((callback == null) || (callback.GuestPasses == null)) {
|
||||||
|
Logging.LogNullError(nameof(callback) + " || " + nameof(callback.GuestPasses), BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((callback.CountGuestPassesToRedeem == 0) || (callback.GuestPasses.Count == 0) || !BotConfig.AcceptGifts) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1518,7 +1641,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void OnChatInvite(SteamFriends.ChatInviteCallback callback) {
|
private void OnChatInvite(SteamFriends.ChatInviteCallback callback) {
|
||||||
if ((callback == null) || !IsMaster(callback.PatronID)) {
|
if ((callback == null) || (callback.ChatRoomID == null) || (callback.PatronID == null)) {
|
||||||
|
Logging.LogNullError(nameof(callback) + " || " + nameof(callback.ChatRoomID) + " || " + nameof(callback.PatronID), BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsMaster(callback.PatronID)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1526,7 +1654,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async void OnChatMsg(SteamFriends.ChatMsgCallback callback) {
|
private async void OnChatMsg(SteamFriends.ChatMsgCallback callback) {
|
||||||
if ((callback == null) || (callback.ChatMsgType != EChatEntryType.ChatMsg)) {
|
if ((callback == null) || (callback.ChatRoomID == null) || (callback.ChatterID == null) || string.IsNullOrEmpty(callback.Message)) {
|
||||||
|
Logging.LogNullError(nameof(callback) + " || " + nameof(callback.ChatRoomID) + " || " + nameof(callback.ChatterID) + " || " + nameof(callback.Message), BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callback.ChatMsgType != EChatEntryType.ChatMsg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1545,7 +1678,8 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void OnFriendsList(SteamFriends.FriendsListCallback callback) {
|
private void OnFriendsList(SteamFriends.FriendsListCallback callback) {
|
||||||
if (callback == null) {
|
if ((callback == null) || (callback.FriendList == null)) {
|
||||||
|
Logging.LogNullError(nameof(callback) + " || " + nameof(callback.FriendList), BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1566,7 +1700,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async void OnFriendMsg(SteamFriends.FriendMsgCallback callback) {
|
private async void OnFriendMsg(SteamFriends.FriendMsgCallback callback) {
|
||||||
if ((callback == null) || (callback.EntryType != EChatEntryType.ChatMsg)) {
|
if ((callback == null) || (callback.Sender == null) || string.IsNullOrEmpty(callback.Message)) {
|
||||||
|
Logging.LogNullError(nameof(callback) + " || " + nameof(callback.Sender) + " || " + nameof(callback.Message), BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callback.EntryType != EChatEntryType.ChatMsg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1574,7 +1713,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async void OnFriendMsgHistory(SteamFriends.FriendMsgHistoryCallback callback) {
|
private async void OnFriendMsgHistory(SteamFriends.FriendMsgHistoryCallback callback) {
|
||||||
if ((callback == null) || (callback.Result != EResult.OK) || (callback.Messages.Count == 0) || !IsMaster(callback.SteamID)) {
|
if ((callback == null) || (callback.Messages == null) || (callback.SteamID == null)) {
|
||||||
|
Logging.LogNullError(nameof(callback) + " || " + nameof(callback.Messages) + " || " + nameof(callback.SteamID), BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((callback.Messages.Count == 0) || !IsMaster(callback.SteamID)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1597,6 +1741,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private void OnAccountInfo(SteamUser.AccountInfoCallback callback) {
|
private void OnAccountInfo(SteamUser.AccountInfoCallback callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
|
Logging.LogNullError(nameof(callback), BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1607,6 +1752,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private void OnLoggedOff(SteamUser.LoggedOffCallback callback) {
|
private void OnLoggedOff(SteamUser.LoggedOffCallback callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
|
Logging.LogNullError(nameof(callback), BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1615,6 +1761,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private async void OnLoggedOn(SteamUser.LoggedOnCallback callback) {
|
private async void OnLoggedOn(SteamUser.LoggedOnCallback callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
|
Logging.LogNullError(nameof(callback), BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1714,7 +1861,8 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void OnLoginKey(SteamUser.LoginKeyCallback callback) {
|
private void OnLoginKey(SteamUser.LoginKeyCallback callback) {
|
||||||
if (callback == null) {
|
if ((callback == null) || string.IsNullOrEmpty(callback.LoginKey)) {
|
||||||
|
Logging.LogNullError(nameof(callback) + " || " + nameof(callback.LoginKey), BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1724,21 +1872,27 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private void OnMachineAuth(SteamUser.UpdateMachineAuthCallback callback) {
|
private void OnMachineAuth(SteamUser.UpdateMachineAuthCallback callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
|
Logging.LogNullError(nameof(callback), BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fileSize;
|
int fileSize;
|
||||||
byte[] sentryHash;
|
byte[] sentryHash;
|
||||||
|
|
||||||
using (FileStream fileStream = File.Open(SentryFile, FileMode.OpenOrCreate, FileAccess.ReadWrite)) {
|
try {
|
||||||
fileStream.Seek(callback.Offset, SeekOrigin.Begin);
|
using (FileStream fileStream = File.Open(SentryFile, FileMode.OpenOrCreate, FileAccess.ReadWrite)) {
|
||||||
fileStream.Write(callback.Data, 0, callback.BytesToWrite);
|
fileStream.Seek(callback.Offset, SeekOrigin.Begin);
|
||||||
fileSize = (int) fileStream.Length;
|
fileStream.Write(callback.Data, 0, callback.BytesToWrite);
|
||||||
|
fileSize = (int) fileStream.Length;
|
||||||
|
|
||||||
fileStream.Seek(0, SeekOrigin.Begin);
|
fileStream.Seek(0, SeekOrigin.Begin);
|
||||||
using (SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider()) {
|
using (SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider()) {
|
||||||
sentryHash = sha.ComputeHash(fileStream);
|
sentryHash = sha.ComputeHash(fileStream);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logging.LogGenericException(e, BotName);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inform the steam servers that we're accepting this sentry file
|
// Inform the steam servers that we're accepting this sentry file
|
||||||
@@ -1755,11 +1909,19 @@ namespace ArchiSteamFarm {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[SuppressMessage("ReSharper", "MemberCanBeMadeStatic.Local")]
|
private void OnWebAPIUserNonce(SteamUser.WebAPIUserNonceCallback callback) {
|
||||||
private void OnWebAPIUserNonce(SteamUser.WebAPIUserNonceCallback callback) { }
|
if (callback == null) {
|
||||||
|
Logging.LogNullError(nameof(callback), BotName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async void OnNotifications(ArchiHandler.NotificationsCallback callback) {
|
private async void OnNotifications(ArchiHandler.NotificationsCallback callback) {
|
||||||
if ((callback == null) || (callback.Notifications == null)) {
|
if (callback == null) {
|
||||||
|
Logging.LogNullError(nameof(callback), BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((callback.Notifications == null) || (callback.Notifications.Count == 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1786,11 +1948,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void OnOfflineMessage(ArchiHandler.OfflineMessageCallback callback) {
|
private void OnOfflineMessage(ArchiHandler.OfflineMessageCallback callback) {
|
||||||
if ((callback == null) || (callback.OfflineMessagesCount == 0)) {
|
if (callback == null) {
|
||||||
|
Logging.LogNullError(nameof(callback), BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!BotConfig.HandleOfflineMessages) {
|
if ((callback.OfflineMessagesCount == 0) || !BotConfig.HandleOfflineMessages) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1819,6 +1982,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private void OnPurchaseResponse(ArchiHandler.PurchaseResponseCallback callback) {
|
private void OnPurchaseResponse(ArchiHandler.PurchaseResponseCallback callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
|
Logging.LogNullError(nameof(callback), BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,11 +105,17 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
|
|
||||||
internal static BotConfig Load(string filePath) {
|
internal static BotConfig Load(string filePath) {
|
||||||
if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath)) {
|
if (string.IsNullOrEmpty(filePath)) {
|
||||||
|
Logging.LogNullError(nameof(filePath));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!File.Exists(filePath)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
BotConfig botConfig;
|
BotConfig botConfig;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
botConfig = JsonConvert.DeserializeObject<BotConfig>(File.ReadAllText(filePath));
|
botConfig = JsonConvert.DeserializeObject<BotConfig>(File.ReadAllText(filePath));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal static BotDatabase Load(string filePath) {
|
internal static BotDatabase Load(string filePath) {
|
||||||
if (string.IsNullOrEmpty(filePath)) {
|
if (string.IsNullOrEmpty(filePath)) {
|
||||||
|
Logging.LogNullError(nameof(filePath));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +77,7 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BotDatabase botDatabase;
|
BotDatabase botDatabase;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
botDatabase = JsonConvert.DeserializeObject<BotDatabase>(File.ReadAllText(filePath));
|
botDatabase = JsonConvert.DeserializeObject<BotDatabase>(File.ReadAllText(filePath));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -84,6 +86,7 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (botDatabase == null) {
|
if (botDatabase == null) {
|
||||||
|
Logging.LogNullError(nameof(botDatabase));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static HashSet<uint> GetGamesToFarmSolo(ConcurrentDictionary<uint, float> gamesToFarm) {
|
private static HashSet<uint> GetGamesToFarmSolo(ConcurrentDictionary<uint, float> gamesToFarm) {
|
||||||
if (gamesToFarm == null) {
|
if (gamesToFarm == null) {
|
||||||
|
Logging.LogNullError(nameof(gamesToFarm));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,11 +250,13 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private void CheckPage(HtmlDocument htmlDocument) {
|
private void CheckPage(HtmlDocument htmlDocument) {
|
||||||
if (htmlDocument == null) {
|
if (htmlDocument == null) {
|
||||||
|
Logging.LogNullError(nameof(htmlDocument), Bot.BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HtmlNodeCollection htmlNodes = htmlDocument.DocumentNode.SelectNodes("//div[@class='badge_title_stats']");
|
HtmlNodeCollection htmlNodes = htmlDocument.DocumentNode.SelectNodes("//div[@class='badge_title_stats']");
|
||||||
if (htmlNodes == null) {
|
if (htmlNodes == null) {
|
||||||
|
Logging.LogNullError(nameof(htmlNodes), Bot.BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,32 +268,27 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
string steamLink = farmingNode.GetAttributeValue("href", null);
|
string steamLink = farmingNode.GetAttributeValue("href", null);
|
||||||
if (string.IsNullOrEmpty(steamLink)) {
|
if (string.IsNullOrEmpty(steamLink)) {
|
||||||
Logging.LogNullError("steamLink", Bot.BotName);
|
Logging.LogNullError(nameof(steamLink), Bot.BotName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = steamLink.LastIndexOf('/');
|
int index = steamLink.LastIndexOf('/');
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
Logging.LogNullError("index", Bot.BotName);
|
Logging.LogNullError(nameof(index), Bot.BotName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
if (steamLink.Length <= index) {
|
if (steamLink.Length <= index) {
|
||||||
Logging.LogNullError("length", Bot.BotName);
|
Logging.LogNullError(nameof(steamLink.Length), Bot.BotName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
steamLink = steamLink.Substring(index);
|
steamLink = steamLink.Substring(index);
|
||||||
|
|
||||||
uint appID;
|
uint appID;
|
||||||
if (!uint.TryParse(steamLink, out appID)) {
|
if (!uint.TryParse(steamLink, out appID) || (appID == 0)) {
|
||||||
Logging.LogNullError("appID", Bot.BotName);
|
Logging.LogNullError(nameof(appID), Bot.BotName);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (appID == 0) {
|
|
||||||
Logging.LogNullError("appID", Bot.BotName);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,13 +298,13 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
HtmlNode timeNode = htmlNode.SelectSingleNode(".//div[@class='badge_title_stats_playtime']");
|
HtmlNode timeNode = htmlNode.SelectSingleNode(".//div[@class='badge_title_stats_playtime']");
|
||||||
if (timeNode == null) {
|
if (timeNode == null) {
|
||||||
Logging.LogNullError("timeNode", Bot.BotName);
|
Logging.LogNullError(nameof(timeNode), Bot.BotName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
string hoursString = timeNode.InnerText;
|
string hoursString = timeNode.InnerText;
|
||||||
if (string.IsNullOrEmpty(hoursString)) {
|
if (string.IsNullOrEmpty(hoursString)) {
|
||||||
Logging.LogNullError("hoursString", Bot.BotName);
|
Logging.LogNullError(nameof(hoursString), Bot.BotName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,7 +312,10 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
Match match = Regex.Match(hoursString, @"[0-9\.,]+");
|
Match match = Regex.Match(hoursString, @"[0-9\.,]+");
|
||||||
if (match.Success) {
|
if (match.Success) {
|
||||||
float.TryParse(match.Value, NumberStyles.Number, CultureInfo.InvariantCulture, out hours);
|
if (!float.TryParse(match.Value, NumberStyles.Number, CultureInfo.InvariantCulture, out hours)) {
|
||||||
|
Logging.LogNullError(nameof(hours), Bot.BotName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GamesToFarm[appID] = hours;
|
GamesToFarm[appID] = hours;
|
||||||
@@ -323,6 +324,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private async Task CheckPage(byte page) {
|
private async Task CheckPage(byte page) {
|
||||||
if (page == 0) {
|
if (page == 0) {
|
||||||
|
Logging.LogNullError(nameof(page), Bot.BotName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,6 +346,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private async Task<bool?> ShouldFarm(uint appID) {
|
private async Task<bool?> ShouldFarm(uint appID) {
|
||||||
if (appID == 0) {
|
if (appID == 0) {
|
||||||
|
Logging.LogNullError(nameof(appID), Bot.BotName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,11 +356,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HtmlNode htmlNode = htmlDocument.DocumentNode.SelectSingleNode("//span[@class='progress_info_bold']");
|
HtmlNode htmlNode = htmlDocument.DocumentNode.SelectSingleNode("//span[@class='progress_info_bold']");
|
||||||
if (htmlNode == null) {
|
if (htmlNode != null) {
|
||||||
return null;
|
return !htmlNode.InnerText.Contains("No card drops");
|
||||||
}
|
}
|
||||||
|
|
||||||
return !htmlNode.InnerText.Contains("No card drops");
|
Logging.LogNullError(nameof(htmlNode), Bot.BotName);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool FarmMultiple() {
|
private bool FarmMultiple() {
|
||||||
@@ -387,6 +391,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private async Task<bool> FarmSolo(uint appID) {
|
private async Task<bool> FarmSolo(uint appID) {
|
||||||
if (appID == 0) {
|
if (appID == 0) {
|
||||||
|
Logging.LogNullError(nameof(appID), Bot.BotName);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,6 +418,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private async Task<bool> Farm(uint appID) {
|
private async Task<bool> Farm(uint appID) {
|
||||||
if (appID == 0) {
|
if (appID == 0) {
|
||||||
|
Logging.LogNullError(nameof(appID), Bot.BotName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,6 +447,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private bool FarmHours(float maxHour, ConcurrentHashSet<uint> appIDs) {
|
private bool FarmHours(float maxHour, ConcurrentHashSet<uint> appIDs) {
|
||||||
if ((maxHour < 0) || (appIDs == null) || (appIDs.Count == 0)) {
|
if ((maxHour < 0) || (appIDs == null) || (appIDs.Count == 0)) {
|
||||||
|
Logging.LogNullError(nameof(maxHour) + " || " + nameof(appIDs) + " || " + nameof(appIDs.Count), Bot.BotName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal DebugListener(string filePath) {
|
internal DebugListener(string filePath) {
|
||||||
if (string.IsNullOrEmpty(filePath)) {
|
if (string.IsNullOrEmpty(filePath)) {
|
||||||
return;
|
throw new ArgumentNullException(nameof(filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath = filePath;
|
FilePath = filePath;
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal static GlobalConfig Load(string filePath) {
|
internal static GlobalConfig Load(string filePath) {
|
||||||
if (string.IsNullOrEmpty(filePath)) {
|
if (string.IsNullOrEmpty(filePath)) {
|
||||||
|
Logging.LogNullError(nameof(filePath));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +121,7 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GlobalConfig globalConfig;
|
GlobalConfig globalConfig;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
globalConfig = JsonConvert.DeserializeObject<GlobalConfig>(File.ReadAllText(filePath));
|
globalConfig = JsonConvert.DeserializeObject<GlobalConfig>(File.ReadAllText(filePath));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -128,6 +130,7 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (globalConfig == null) {
|
if (globalConfig == null) {
|
||||||
|
Logging.LogNullError(nameof(globalConfig));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal static GlobalDatabase Load(string filePath) {
|
internal static GlobalDatabase Load(string filePath) {
|
||||||
if (string.IsNullOrEmpty(filePath)) {
|
if (string.IsNullOrEmpty(filePath)) {
|
||||||
|
Logging.LogNullError(nameof(filePath));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +59,7 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GlobalDatabase globalDatabase;
|
GlobalDatabase globalDatabase;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
globalDatabase = JsonConvert.DeserializeObject<GlobalDatabase>(File.ReadAllText(filePath));
|
globalDatabase = JsonConvert.DeserializeObject<GlobalDatabase>(File.ReadAllText(filePath));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -66,6 +68,7 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (globalDatabase == null) {
|
if (globalDatabase == null) {
|
||||||
|
Logging.LogNullError(nameof(globalDatabase));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal static void LogGenericWTF(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
|
internal static void LogGenericWTF(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
|
||||||
if (string.IsNullOrEmpty(message)) {
|
if (string.IsNullOrEmpty(message)) {
|
||||||
|
LogNullError(nameof(message), botName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +66,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal static void LogGenericError(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
|
internal static void LogGenericError(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
|
||||||
if (string.IsNullOrEmpty(message)) {
|
if (string.IsNullOrEmpty(message)) {
|
||||||
|
LogNullError(nameof(message), botName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +76,7 @@ namespace ArchiSteamFarm {
|
|||||||
internal static void LogGenericException(Exception exception, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
|
internal static void LogGenericException(Exception exception, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (exception == null) {
|
if (exception == null) {
|
||||||
|
LogNullError(nameof(exception), botName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,6 +94,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal static void LogGenericWarning(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
|
internal static void LogGenericWarning(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
|
||||||
if (string.IsNullOrEmpty(message)) {
|
if (string.IsNullOrEmpty(message)) {
|
||||||
|
LogNullError(nameof(message), botName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +103,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal static void LogGenericInfo(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
|
internal static void LogGenericInfo(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
|
||||||
if (string.IsNullOrEmpty(message)) {
|
if (string.IsNullOrEmpty(message)) {
|
||||||
|
LogNullError(nameof(message), botName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,16 +112,21 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
[SuppressMessage("ReSharper", "ExplicitCallerInfoArgument")]
|
[SuppressMessage("ReSharper", "ExplicitCallerInfoArgument")]
|
||||||
internal static void LogNullError(string nullObjectName, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
|
internal static void LogNullError(string nullObjectName, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
|
||||||
if (string.IsNullOrEmpty(nullObjectName)) {
|
while (true) {
|
||||||
return;
|
if (string.IsNullOrEmpty(nullObjectName)) {
|
||||||
}
|
nullObjectName = nameof(nullObjectName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
LogGenericError(nullObjectName + " is null!", botName, previousMethodName);
|
LogGenericError(nullObjectName + " is null!", botName, previousMethodName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Conditional("DEBUG"), SuppressMessage("ReSharper", "UnusedMember.Global")]
|
[Conditional("DEBUG"), SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||||
internal static void LogGenericDebug(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
|
internal static void LogGenericDebug(string message, string botName = "Main", [CallerMemberName] string previousMethodName = null) {
|
||||||
if (string.IsNullOrEmpty(message)) {
|
if (string.IsNullOrEmpty(message)) {
|
||||||
|
LogNullError(nameof(message), botName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,6 +135,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static void Log(string message) {
|
private static void Log(string message) {
|
||||||
if (string.IsNullOrEmpty(message)) {
|
if (string.IsNullOrEmpty(message)) {
|
||||||
|
LogNullError(nameof(message));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,8 +145,7 @@ namespace ArchiSteamFarm {
|
|||||||
if (!Program.ConsoleIsBusy) {
|
if (!Program.ConsoleIsBusy) {
|
||||||
try {
|
try {
|
||||||
Console.Write(loggedMessage);
|
Console.Write(loggedMessage);
|
||||||
}
|
} catch {
|
||||||
catch {
|
|
||||||
// Ignored
|
// Ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,12 +110,9 @@ namespace ArchiSteamFarm {
|
|||||||
releaseURL += "/latest";
|
releaseURL += "/latest";
|
||||||
}
|
}
|
||||||
|
|
||||||
string response = null;
|
|
||||||
Logging.LogGenericInfo("Checking new version...");
|
Logging.LogGenericInfo("Checking new version...");
|
||||||
for (byte i = 0; (i < WebBrowser.MaxRetries) && string.IsNullOrEmpty(response); i++) {
|
|
||||||
response = await WebBrowser.UrlGetToContent(releaseURL).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
string response = await WebBrowser.UrlGetToContentRetry(releaseURL).ConfigureAwait(false);
|
||||||
if (string.IsNullOrEmpty(response)) {
|
if (string.IsNullOrEmpty(response)) {
|
||||||
Logging.LogGenericWarning("Could not check latest version!");
|
Logging.LogGenericWarning("Could not check latest version!");
|
||||||
return;
|
return;
|
||||||
@@ -202,14 +199,8 @@ namespace ArchiSteamFarm {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] result = null;
|
byte[] result = await WebBrowser.UrlGetToBytesRetry(binaryAsset.DownloadURL).ConfigureAwait(false);
|
||||||
for (byte i = 0; (i < WebBrowser.MaxRetries) && (result == null); i++) {
|
|
||||||
Logging.LogGenericInfo("Downloading new version...");
|
|
||||||
result = await WebBrowser.UrlGetToBytes(binaryAsset.DownloadURL).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +271,7 @@ namespace ArchiSteamFarm {
|
|||||||
Exit();
|
Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetUserInput(EUserInputType userInputType, string botName = null, string extraInformation = null) {
|
internal static string GetUserInput(EUserInputType userInputType, string botName = "Main", string extraInformation = null) {
|
||||||
if (userInputType == EUserInputType.Unknown) {
|
if (userInputType == EUserInputType.Unknown) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -295,49 +286,51 @@ namespace ArchiSteamFarm {
|
|||||||
ConsoleIsBusy = true;
|
ConsoleIsBusy = true;
|
||||||
switch (userInputType) {
|
switch (userInputType) {
|
||||||
case EUserInputType.DeviceID:
|
case EUserInputType.DeviceID:
|
||||||
Console.Write((string.IsNullOrEmpty(botName) ? "" : "<" + botName + "> ") + "Please enter your Device ID (including \"android:\"): ");
|
Console.Write("<" + botName + "> Please enter your Device ID (including \"android:\"): ");
|
||||||
break;
|
break;
|
||||||
case EUserInputType.Login:
|
case EUserInputType.Login:
|
||||||
Console.Write((string.IsNullOrEmpty(botName) ? "" : "<" + botName + "> ") + "Please enter your login: ");
|
Console.Write("<" + botName + "> Please enter your login: ");
|
||||||
break;
|
break;
|
||||||
case EUserInputType.Password:
|
case EUserInputType.Password:
|
||||||
Console.Write((string.IsNullOrEmpty(botName) ? "" : "<" + botName + "> ") + "Please enter your password: ");
|
Console.Write("<" + botName + "> Please enter your password: ");
|
||||||
break;
|
break;
|
||||||
case EUserInputType.PhoneNumber:
|
case EUserInputType.PhoneNumber:
|
||||||
Console.Write((string.IsNullOrEmpty(botName) ? "" : "<" + botName + "> ") + "Please enter your full phone number (e.g. +1234567890): ");
|
Console.Write("<" + botName + "> Please enter your full phone number (e.g. +1234567890): ");
|
||||||
break;
|
break;
|
||||||
case EUserInputType.SMS:
|
case EUserInputType.SMS:
|
||||||
Console.Write((string.IsNullOrEmpty(botName) ? "" : "<" + botName + "> ") + "Please enter SMS code sent on your mobile: ");
|
Console.Write("<" + botName + "> Please enter SMS code sent on your mobile: ");
|
||||||
break;
|
break;
|
||||||
case EUserInputType.SteamGuard:
|
case EUserInputType.SteamGuard:
|
||||||
Console.Write((string.IsNullOrEmpty(botName) ? "" : "<" + botName + "> ") + "Please enter the auth code sent to your email: ");
|
Console.Write("<" + botName + "> Please enter the auth code sent to your email: ");
|
||||||
break;
|
break;
|
||||||
case EUserInputType.SteamParentalPIN:
|
case EUserInputType.SteamParentalPIN:
|
||||||
Console.Write((string.IsNullOrEmpty(botName) ? "" : "<" + botName + "> ") + "Please enter steam parental PIN: ");
|
Console.Write("<" + botName + "> Please enter steam parental PIN: ");
|
||||||
break;
|
break;
|
||||||
case EUserInputType.RevocationCode:
|
case EUserInputType.RevocationCode:
|
||||||
Console.WriteLine((string.IsNullOrEmpty(botName) ? "" : "<" + botName + "> ") + "PLEASE WRITE DOWN YOUR REVOCATION CODE: " + extraInformation);
|
Console.WriteLine("<" + botName + "> PLEASE WRITE DOWN YOUR REVOCATION CODE: " + extraInformation);
|
||||||
Console.Write("Hit enter once ready...");
|
Console.Write("<" + botName + "> Hit enter once ready...");
|
||||||
break;
|
break;
|
||||||
case EUserInputType.TwoFactorAuthentication:
|
case EUserInputType.TwoFactorAuthentication:
|
||||||
Console.Write((string.IsNullOrEmpty(botName) ? "" : "<" + botName + "> ") + "Please enter your 2 factor auth code from your authenticator app: ");
|
Console.Write("<" + botName + "> Please enter your 2 factor auth code from your authenticator app: ");
|
||||||
break;
|
break;
|
||||||
case EUserInputType.WCFHostname:
|
case EUserInputType.WCFHostname:
|
||||||
Console.Write((string.IsNullOrEmpty(botName) ? "" : "<" + botName + "> ") + "Please enter your WCF hostname: ");
|
Console.Write("<" + botName + "> Please enter your WCF hostname: ");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.Write((string.IsNullOrEmpty(botName) ? "" : "<" + botName + "> ") + "Please enter not documented yet value of \"" + userInputType + "\": ");
|
Console.Write("<" + botName + "> Please enter not documented yet value of \"" + userInputType + "\": ");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = Console.ReadLine();
|
result = Console.ReadLine();
|
||||||
|
|
||||||
if (!Console.IsOutputRedirected) {
|
if (!Console.IsOutputRedirected) {
|
||||||
Console.Clear(); // For security purposes
|
Console.Clear(); // For security purposes
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsoleIsBusy = false;
|
ConsoleIsBusy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return string.IsNullOrEmpty(result) ? null : result.Trim();
|
return !string.IsNullOrEmpty(result) ? result.Trim() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void OnBotShutdown() {
|
internal static void OnBotShutdown() {
|
||||||
@@ -378,11 +371,14 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private static void ParseArgs(IEnumerable<string> args) {
|
private static void ParseArgs(IEnumerable<string> args) {
|
||||||
if (args == null) {
|
if (args == null) {
|
||||||
|
Logging.LogNullError(nameof(args));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (string arg in args) {
|
foreach (string arg in args) {
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
|
case "":
|
||||||
|
break;
|
||||||
case "--client":
|
case "--client":
|
||||||
Mode = EMode.Client;
|
Mode = EMode.Client;
|
||||||
break;
|
break;
|
||||||
@@ -416,7 +412,8 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) {
|
private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) {
|
||||||
if ((sender == null) || (args == null)) {
|
if ((sender == null) || (args == null) || (args.ExceptionObject == null)) {
|
||||||
|
Logging.LogNullError(nameof(sender) + " || " + nameof(args) + " || " + nameof(args.ExceptionObject));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -424,7 +421,8 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs args) {
|
private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs args) {
|
||||||
if ((sender == null) || (args == null)) {
|
if ((sender == null) || (args == null) || (args.Exception == null)) {
|
||||||
|
Logging.LogNullError(nameof(sender) + " || " + nameof(args) + " || " + nameof(args.Exception));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,7 +467,9 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse args
|
// Parse args
|
||||||
ParseArgs(args);
|
if (args != null) {
|
||||||
|
ParseArgs(args);
|
||||||
|
}
|
||||||
|
|
||||||
// If we ran ASF as a client, we're done by now
|
// If we ran ASF as a client, we're done by now
|
||||||
if (Mode == EMode.Client) {
|
if (Mode == EMode.Client) {
|
||||||
@@ -501,12 +501,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bot bot = new Bot(botName);
|
Bot bot = new Bot(botName);
|
||||||
if ((bot.BotConfig != null) && bot.BotConfig.Enabled) {
|
if ((bot.BotConfig == null) || !bot.BotConfig.Enabled) {
|
||||||
if (bot.BotConfig.StartOnLaunch) {
|
continue;
|
||||||
isRunning = true;
|
}
|
||||||
}
|
|
||||||
} else {
|
if (bot.BotConfig.StartOnLaunch) {
|
||||||
Logging.LogGenericInfo("Not starting this instance because it's disabled in config file", botName);
|
isRunning = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task ParseTrade(Steam.TradeOffer tradeOffer) {
|
private async Task ParseTrade(Steam.TradeOffer tradeOffer) {
|
||||||
if ((tradeOffer == null) || (tradeOffer.State != Steam.TradeOffer.ETradeOfferState.Active)) {
|
if (tradeOffer == null) {
|
||||||
|
Logging.LogNullError(nameof(tradeOffer), Bot.BotName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tradeOffer.State != Steam.TradeOffer.ETradeOfferState.Active) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,6 +114,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private async Task<bool> ShouldAcceptTrade(Steam.TradeOffer tradeOffer) {
|
private async Task<bool> ShouldAcceptTrade(Steam.TradeOffer tradeOffer) {
|
||||||
if (tradeOffer == null) {
|
if (tradeOffer == null) {
|
||||||
|
Logging.LogNullError(nameof(tradeOffer), Bot.BotName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,17 +34,41 @@ namespace ArchiSteamFarm {
|
|||||||
[SuppressMessage("ReSharper", "UnusedParameter.Global")]
|
[SuppressMessage("ReSharper", "UnusedParameter.Global")]
|
||||||
internal static void Forget(this Task task) { }
|
internal static void Forget(this Task task) { }
|
||||||
|
|
||||||
internal static Task ForEachAsync<T>(this IEnumerable<T> sequence, Func<T, Task> action) => action == null ? Task.FromResult(true) : Task.WhenAll(sequence.Select(action));
|
internal static Task ForEachAsync<T>(this IEnumerable<T> sequence, Func<T, Task> action) {
|
||||||
|
if (action != null) {
|
||||||
|
return Task.WhenAll(sequence.Select(action));
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.LogNullError(nameof(action));
|
||||||
|
return Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
internal static string GetCookieValue(this CookieContainer cookieContainer, string url, string name) {
|
internal static string GetCookieValue(this CookieContainer cookieContainer, string url, string name) {
|
||||||
if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(name)) {
|
if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(name)) {
|
||||||
|
Logging.LogNullError(nameof(url) + " || " + nameof(name));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CookieCollection cookies = cookieContainer.GetCookies(new Uri(url));
|
Uri uri;
|
||||||
return cookies.Count == 0 ? null : (from Cookie cookie in cookies where cookie.Name.Equals(name, StringComparison.Ordinal) select cookie.Value).FirstOrDefault();
|
|
||||||
|
try {
|
||||||
|
uri = new Uri(url);
|
||||||
|
} catch (UriFormatException e) {
|
||||||
|
Logging.LogGenericException(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
CookieCollection cookies = cookieContainer.GetCookies(uri);
|
||||||
|
return cookies.Count == 0 ? null : (from Cookie cookie in cookies where cookie.Name.Equals(name) select cookie.Value).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Task SleepAsync(int miliseconds) => miliseconds < 0 ? Task.FromResult(true) : Task.Delay(miliseconds);
|
internal static Task SleepAsync(int miliseconds) {
|
||||||
|
if (miliseconds >= 0) {
|
||||||
|
return Task.Delay(miliseconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.LogNullError(nameof(miliseconds));
|
||||||
|
return Task.FromResult(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,11 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal string SendCommand(string input) {
|
internal string SendCommand(string input) {
|
||||||
|
if (string.IsNullOrEmpty(input)) {
|
||||||
|
Logging.LogNullError(nameof(input));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (Client == null) {
|
if (Client == null) {
|
||||||
Client = new Client(new BasicHttpBinding(), new EndpointAddress(URL));
|
Client = new Client(new BasicHttpBinding(), new EndpointAddress(URL));
|
||||||
}
|
}
|
||||||
@@ -96,6 +101,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
public string HandleCommand(string input) {
|
public string HandleCommand(string input) {
|
||||||
if (string.IsNullOrEmpty(input)) {
|
if (string.IsNullOrEmpty(input)) {
|
||||||
|
Logging.LogNullError(nameof(input));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +126,11 @@ namespace ArchiSteamFarm {
|
|||||||
internal Client(Binding binding, EndpointAddress address) : base(binding, address) { }
|
internal Client(Binding binding, EndpointAddress address) : base(binding, address) { }
|
||||||
|
|
||||||
public string HandleCommand(string input) {
|
public string HandleCommand(string input) {
|
||||||
|
if (string.IsNullOrEmpty(input)) {
|
||||||
|
Logging.LogNullError(nameof(input));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return Channel.HandleCommand(input);
|
return Channel.HandleCommand(input);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -82,42 +82,161 @@ namespace ArchiSteamFarm {
|
|||||||
HttpClient.DefaultRequestHeaders.UserAgent.ParseAdd(DefaultUserAgent);
|
HttpClient.DefaultRequestHeaders.UserAgent.ParseAdd(DefaultUserAgent);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<bool> UrlHead(string request, string referer = null) {
|
internal async Task<bool> UrlHeadRetry(string request, string referer = null) {
|
||||||
if (string.IsNullOrEmpty(request)) {
|
if (string.IsNullOrEmpty(request)) {
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (HttpResponseMessage response = await UrlHeadToResponse(request, referer).ConfigureAwait(false)) {
|
bool result = false;
|
||||||
return response != null;
|
for (byte i = 0; (i < MaxRetries) && !result; i++) {
|
||||||
|
result = await UrlHead(request, referer).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.LogGenericWTF("Request failed even after " + MaxRetries + " tries", Identifier);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<Uri> UrlHeadToUri(string request, string referer = null) {
|
internal async Task<Uri> UrlHeadToUriRetry(string request, string referer = null) {
|
||||||
if (string.IsNullOrEmpty(request)) {
|
if (string.IsNullOrEmpty(request)) {
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (HttpResponseMessage response = await UrlHeadToResponse(request, referer).ConfigureAwait(false)) {
|
Uri result = null;
|
||||||
return response == null ? null : response.RequestMessage.RequestUri;
|
for (byte i = 0; (i < MaxRetries) && (result == null); i++) {
|
||||||
|
result = await UrlHeadToUri(request, referer).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.LogGenericWTF("Request failed even after " + MaxRetries + " tries", Identifier);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<string> UrlGetToContent(string request, string referer = null) {
|
internal async Task<byte[]> UrlGetToBytesRetry(string request, string referer = null) {
|
||||||
if (string.IsNullOrEmpty(request)) {
|
if (string.IsNullOrEmpty(request)) {
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (HttpResponseMessage httpResponse = await UrlGetToResponse(request, referer).ConfigureAwait(false)) {
|
byte[] result = null;
|
||||||
if (httpResponse == null) {
|
for (byte i = 0; (i < MaxRetries) && (result == null); i++) {
|
||||||
return null;
|
result = await UrlGetToBytes(request, referer).ConfigureAwait(false);
|
||||||
}
|
|
||||||
|
|
||||||
return await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.LogGenericWTF("Request failed even after " + MaxRetries + " tries", Identifier);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<byte[]> UrlGetToBytes(string request, string referer = null) {
|
internal async Task<string> UrlGetToContentRetry(string request, string referer = null) {
|
||||||
if (string.IsNullOrEmpty(request)) {
|
if (string.IsNullOrEmpty(request)) {
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
string result = null;
|
||||||
|
for (byte i = 0; (i < MaxRetries) && string.IsNullOrEmpty(result); i++) {
|
||||||
|
result = await UrlGetToContent(request, referer).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(result)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.LogGenericWTF("Request failed even after " + MaxRetries + " tries", Identifier);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal async Task<HtmlDocument> UrlGetToHtmlDocumentRetry(string request, string referer = null) {
|
||||||
|
if (string.IsNullOrEmpty(request)) {
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
HtmlDocument result = null;
|
||||||
|
for (byte i = 0; (i < MaxRetries) && (result == null); i++) {
|
||||||
|
result = await UrlGetToHtmlDocument(request, referer).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.LogGenericWTF("Request failed even after " + MaxRetries + " tries", Identifier);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal async Task<JObject> UrlGetToJObjectRetry(string request, string referer = null) {
|
||||||
|
if (string.IsNullOrEmpty(request)) {
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
JObject result = null;
|
||||||
|
for (byte i = 0; (i < MaxRetries) && (result == null); i++) {
|
||||||
|
result = await UrlGetToJObject(request, referer).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.LogGenericWTF("Request failed even after " + MaxRetries + " tries", Identifier);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal async Task<XmlDocument> UrlGetToXMLRetry(string request, string referer = null) {
|
||||||
|
if (string.IsNullOrEmpty(request)) {
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
XmlDocument result = null;
|
||||||
|
for (byte i = 0; (i < MaxRetries) && (result == null); i++) {
|
||||||
|
result = await UrlGetToXML(request, referer).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.LogGenericWTF("Request failed even after " + MaxRetries + " tries", Identifier);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal async Task<bool> UrlPostRetry(string request, Dictionary<string, string> data = null, string referer = null) {
|
||||||
|
if (string.IsNullOrEmpty(request)) {
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool result = false;
|
||||||
|
for (byte i = 0; (i < MaxRetries) && !result; i++) {
|
||||||
|
result = await UrlPost(request, data, referer).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.LogGenericWTF("Request failed even after " + MaxRetries + " tries", Identifier);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<byte[]> UrlGetToBytes(string request, string referer = null) {
|
||||||
|
if (string.IsNullOrEmpty(request)) {
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,8 +249,24 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<HtmlDocument> UrlGetToHtmlDocument(string request, string referer = null) {
|
private async Task<string> UrlGetToContent(string request, string referer = null) {
|
||||||
if (string.IsNullOrEmpty(request)) {
|
if (string.IsNullOrEmpty(request)) {
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (HttpResponseMessage httpResponse = await UrlGetToResponse(request, referer).ConfigureAwait(false)) {
|
||||||
|
if (httpResponse == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<HtmlDocument> UrlGetToHtmlDocument(string request, string referer = null) {
|
||||||
|
if (string.IsNullOrEmpty(request)) {
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,8 +280,9 @@ namespace ArchiSteamFarm {
|
|||||||
return htmlDocument;
|
return htmlDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<JObject> UrlGetToJObject(string request, string referer = null) {
|
private async Task<JObject> UrlGetToJObject(string request, string referer = null) {
|
||||||
if (string.IsNullOrEmpty(request)) {
|
if (string.IsNullOrEmpty(request)) {
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,8 +303,18 @@ namespace ArchiSteamFarm {
|
|||||||
return jObject;
|
return jObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<XmlDocument> UrlGetToXML(string request, string referer = null) {
|
private async Task<HttpResponseMessage> UrlGetToResponse(string request, string referer = null) {
|
||||||
|
if (!string.IsNullOrEmpty(request)) {
|
||||||
|
return await UrlRequest(request, HttpMethod.Get, null, referer).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<XmlDocument> UrlGetToXML(string request, string referer = null) {
|
||||||
if (string.IsNullOrEmpty(request)) {
|
if (string.IsNullOrEmpty(request)) {
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,8 +335,40 @@ namespace ArchiSteamFarm {
|
|||||||
return xmlDocument;
|
return xmlDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<bool> UrlPost(string request, Dictionary<string, string> data = null, string referer = null) {
|
private async Task<bool> UrlHead(string request, string referer = null) {
|
||||||
if (string.IsNullOrEmpty(request)) {
|
if (string.IsNullOrEmpty(request)) {
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (HttpResponseMessage response = await UrlHeadToResponse(request, referer).ConfigureAwait(false)) {
|
||||||
|
return response != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<HttpResponseMessage> UrlHeadToResponse(string request, string referer = null) {
|
||||||
|
if (!string.IsNullOrEmpty(request)) {
|
||||||
|
return await UrlRequest(request, HttpMethod.Head, null, referer).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<Uri> UrlHeadToUri(string request, string referer = null) {
|
||||||
|
if (string.IsNullOrEmpty(request)) {
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (HttpResponseMessage response = await UrlHeadToResponse(request, referer).ConfigureAwait(false)) {
|
||||||
|
return response == null ? null : response.RequestMessage.RequestUri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> UrlPost(string request, Dictionary<string, string> data = null, string referer = null) {
|
||||||
|
if (string.IsNullOrEmpty(request)) {
|
||||||
|
Logging.LogNullError(nameof(request));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,32 +377,18 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<HttpResponseMessage> UrlGetToResponse(string request, string referer = null) {
|
|
||||||
if (string.IsNullOrEmpty(request)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return await UrlRequest(request, HttpMethod.Get, null, referer).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<HttpResponseMessage> UrlHeadToResponse(string request, string referer = null) {
|
|
||||||
if (string.IsNullOrEmpty(request)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return await UrlRequest(request, HttpMethod.Head, null, referer).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<HttpResponseMessage> UrlPostToResponse(string request, Dictionary<string, string> data = null, string referer = null) {
|
private async Task<HttpResponseMessage> UrlPostToResponse(string request, Dictionary<string, string> data = null, string referer = null) {
|
||||||
if (string.IsNullOrEmpty(request)) {
|
if (!string.IsNullOrEmpty(request)) {
|
||||||
return null;
|
return await UrlRequest(request, HttpMethod.Post, data, referer).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await UrlRequest(request, HttpMethod.Post, data, referer).ConfigureAwait(false);
|
Logging.LogNullError(nameof(request));
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<HttpResponseMessage> UrlRequest(string request, HttpMethod httpMethod, Dictionary<string, string> data = null, string referer = null) {
|
private async Task<HttpResponseMessage> UrlRequest(string request, HttpMethod httpMethod, Dictionary<string, string> data = null, string referer = null) {
|
||||||
if (string.IsNullOrEmpty(request) || (httpMethod == null)) {
|
if (string.IsNullOrEmpty(request) || (httpMethod == null)) {
|
||||||
|
Logging.LogNullError(nameof(request) + " || " + nameof(httpMethod));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ namespace ConfigGenerator {
|
|||||||
|
|
||||||
internal void Rename(string botName) {
|
internal void Rename(string botName) {
|
||||||
if (string.IsNullOrEmpty(botName)) {
|
if (string.IsNullOrEmpty(botName)) {
|
||||||
|
Logging.LogNullError(nameof(botName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ namespace ConfigGenerator {
|
|||||||
|
|
||||||
internal static BotConfig Load(string filePath) {
|
internal static BotConfig Load(string filePath) {
|
||||||
if (string.IsNullOrEmpty(filePath)) {
|
if (string.IsNullOrEmpty(filePath)) {
|
||||||
|
Logging.LogNullError(nameof(filePath));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,6 +115,7 @@ namespace ConfigGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BotConfig botConfig;
|
BotConfig botConfig;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
botConfig = JsonConvert.DeserializeObject<BotConfig>(File.ReadAllText(filePath));
|
botConfig = JsonConvert.DeserializeObject<BotConfig>(File.ReadAllText(filePath));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@ namespace ConfigGenerator {
|
|||||||
|
|
||||||
internal ConfigPage(ASFConfig config) {
|
internal ConfigPage(ASFConfig config) {
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
return;
|
throw new ArgumentNullException(nameof(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
ASFConfig = config;
|
ASFConfig = config;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ namespace ConfigGenerator {
|
|||||||
internal static class DialogBox {
|
internal static class DialogBox {
|
||||||
internal static DialogResult InputBox(string title, string promptText, out string value) {
|
internal static DialogResult InputBox(string title, string promptText, out string value) {
|
||||||
if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(promptText)) {
|
if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(promptText)) {
|
||||||
|
Logging.LogNullError(nameof(title) + " || " + nameof(promptText));
|
||||||
value = null;
|
value = null;
|
||||||
return DialogResult.Abort;
|
return DialogResult.Abort;
|
||||||
}
|
}
|
||||||
@@ -80,6 +81,7 @@ namespace ConfigGenerator {
|
|||||||
|
|
||||||
internal static DialogResult YesNoBox(string title, string promptText) {
|
internal static DialogResult YesNoBox(string title, string promptText) {
|
||||||
if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(promptText)) {
|
if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(promptText)) {
|
||||||
|
Logging.LogNullError(nameof(title) + " || " + nameof(promptText));
|
||||||
return DialogResult.Abort;
|
return DialogResult.Abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,12 +43,13 @@ namespace ConfigGenerator {
|
|||||||
ToolbarVisible = false;
|
ToolbarVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnPropertyValueChanged(PropertyValueChangedEventArgs e) {
|
protected override void OnPropertyValueChanged(PropertyValueChangedEventArgs args) {
|
||||||
if (e == null) {
|
if (args == null) {
|
||||||
|
Logging.LogNullError(nameof(args));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.OnPropertyValueChanged(e);
|
base.OnPropertyValueChanged(args);
|
||||||
ASFConfig.Save();
|
ASFConfig.Save();
|
||||||
|
|
||||||
BotConfig botConfig = ASFConfig as BotConfig;
|
BotConfig botConfig = ASFConfig as BotConfig;
|
||||||
@@ -74,12 +75,13 @@ namespace ConfigGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnGotFocus(EventArgs e) {
|
protected override void OnGotFocus(EventArgs args) {
|
||||||
if (e == null) {
|
if (args == null) {
|
||||||
|
Logging.LogNullError(nameof(args));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.OnGotFocus(e);
|
base.OnGotFocus(args);
|
||||||
ASFConfig.Save();
|
ASFConfig.Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ namespace ConfigGenerator {
|
|||||||
|
|
||||||
internal static GlobalConfig Load(string filePath) {
|
internal static GlobalConfig Load(string filePath) {
|
||||||
if (string.IsNullOrEmpty(filePath)) {
|
if (string.IsNullOrEmpty(filePath)) {
|
||||||
|
Logging.LogNullError(nameof(filePath));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,6 +119,7 @@ namespace ConfigGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GlobalConfig globalConfig;
|
GlobalConfig globalConfig;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
globalConfig = JsonConvert.DeserializeObject<GlobalConfig>(File.ReadAllText(filePath));
|
globalConfig = JsonConvert.DeserializeObject<GlobalConfig>(File.ReadAllText(filePath));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -23,22 +23,25 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using ConfigGenerator.Properties;
|
using ConfigGenerator.Properties;
|
||||||
|
|
||||||
namespace ConfigGenerator {
|
namespace ConfigGenerator {
|
||||||
internal static class Logging {
|
internal static class Logging {
|
||||||
internal static void LogGenericInfo(string message) {
|
internal static void LogGenericInfo(string message, [CallerMemberName] string previousMethodName = null) {
|
||||||
if (string.IsNullOrEmpty(message)) {
|
if (string.IsNullOrEmpty(message)) {
|
||||||
|
LogNullError(nameof(message));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageBox.Show(message, Resources.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show(previousMethodName + @"() " + message, Resources.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void LogGenericError(string message, [CallerMemberName] string previousMethodName = null) {
|
internal static void LogGenericError(string message, [CallerMemberName] string previousMethodName = null) {
|
||||||
if (string.IsNullOrEmpty(message)) {
|
if (string.IsNullOrEmpty(message)) {
|
||||||
|
LogNullError(nameof(message));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,6 +51,7 @@ namespace ConfigGenerator {
|
|||||||
internal static void LogGenericException(Exception exception, [CallerMemberName] string previousMethodName = null) {
|
internal static void LogGenericException(Exception exception, [CallerMemberName] string previousMethodName = null) {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (exception == null) {
|
if (exception == null) {
|
||||||
|
LogNullError(nameof(exception));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,10 +68,24 @@ namespace ConfigGenerator {
|
|||||||
|
|
||||||
internal static void LogGenericWarning(string message, [CallerMemberName] string previousMethodName = null) {
|
internal static void LogGenericWarning(string message, [CallerMemberName] string previousMethodName = null) {
|
||||||
if (string.IsNullOrEmpty(message)) {
|
if (string.IsNullOrEmpty(message)) {
|
||||||
|
LogNullError(nameof(message));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageBox.Show(previousMethodName + @"() " + message, Resources.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
MessageBox.Show(previousMethodName + @"() " + message, Resources.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "ExplicitCallerInfoArgument")]
|
||||||
|
internal static void LogNullError(string nullObjectName, [CallerMemberName] string previousMethodName = null) {
|
||||||
|
while (true) {
|
||||||
|
if (string.IsNullOrEmpty(nullObjectName)) {
|
||||||
|
nullObjectName = nameof(nullObjectName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogGenericError(nullObjectName + " is null!", previousMethodName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,8 +45,9 @@ namespace ConfigGenerator {
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainForm_Load(object sender, EventArgs e) {
|
private void MainForm_Load(object sender, EventArgs args) {
|
||||||
if ((sender == null) || (e == null)) {
|
if ((sender == null) || (args == null)) {
|
||||||
|
Logging.LogNullError(nameof(sender) + " || " + nameof(args));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,12 +72,13 @@ namespace ConfigGenerator {
|
|||||||
Tutorial.OnAction(Tutorial.EPhase.Start);
|
Tutorial.OnAction(Tutorial.EPhase.Start);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainTab_Selected(object sender, TabControlEventArgs e) {
|
private void MainTab_Selected(object sender, TabControlEventArgs args) {
|
||||||
if ((sender == null) || (e == null)) {
|
if ((sender == null) || (args == null)) {
|
||||||
|
Logging.LogNullError(nameof(sender) + " || " + nameof(args));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.TabPage == RemoveTab) {
|
if (args.TabPage == RemoveTab) {
|
||||||
ConfigPage configPage = OldTab as ConfigPage;
|
ConfigPage configPage = OldTab as ConfigPage;
|
||||||
if (configPage == null) {
|
if (configPage == null) {
|
||||||
MainTab.SelectedIndex = -1;
|
MainTab.SelectedIndex = -1;
|
||||||
@@ -98,7 +100,7 @@ namespace ConfigGenerator {
|
|||||||
MainTab.SelectedIndex = 0;
|
MainTab.SelectedIndex = 0;
|
||||||
configPage.ASFConfig.Remove();
|
configPage.ASFConfig.Remove();
|
||||||
MainTab.TabPages.Remove(configPage);
|
MainTab.TabPages.Remove(configPage);
|
||||||
} else if (e.TabPage == RenameTab) {
|
} else if (args.TabPage == RenameTab) {
|
||||||
ConfigPage configPage = OldTab as ConfigPage;
|
ConfigPage configPage = OldTab as ConfigPage;
|
||||||
if (configPage == null) {
|
if (configPage == null) {
|
||||||
MainTab.SelectedIndex = -1;
|
MainTab.SelectedIndex = -1;
|
||||||
@@ -128,7 +130,7 @@ namespace ConfigGenerator {
|
|||||||
|
|
||||||
configPage.ASFConfig.Rename(input);
|
configPage.ASFConfig.Rename(input);
|
||||||
configPage.RefreshText();
|
configPage.RefreshText();
|
||||||
} else if (e.TabPage == NewTab) {
|
} else if (args.TabPage == NewTab) {
|
||||||
ConfigPage configPage = OldTab as ConfigPage;
|
ConfigPage configPage = OldTab as ConfigPage;
|
||||||
if (configPage == null) {
|
if (configPage == null) {
|
||||||
MainTab.SelectedIndex = -1;
|
MainTab.SelectedIndex = -1;
|
||||||
@@ -163,33 +165,36 @@ namespace ConfigGenerator {
|
|||||||
MainTab.TabPages.Insert(MainTab.TabPages.Count - ReservedTabs, newConfigPage);
|
MainTab.TabPages.Insert(MainTab.TabPages.Count - ReservedTabs, newConfigPage);
|
||||||
MainTab.SelectedTab = newConfigPage;
|
MainTab.SelectedTab = newConfigPage;
|
||||||
Tutorial.OnAction(Tutorial.EPhase.BotNicknameFinished);
|
Tutorial.OnAction(Tutorial.EPhase.BotNicknameFinished);
|
||||||
} else if (e.TabPage == ASFTab) {
|
} else if (args.TabPage == ASFTab) {
|
||||||
Tutorial.OnAction(Tutorial.EPhase.GlobalConfigOpened);
|
Tutorial.OnAction(Tutorial.EPhase.GlobalConfigOpened);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainTab_Deselecting(object sender, TabControlCancelEventArgs e) {
|
private void MainTab_Deselecting(object sender, TabControlCancelEventArgs args) {
|
||||||
if ((sender == null) || (e == null)) {
|
if ((sender == null) || (args == null)) {
|
||||||
|
Logging.LogNullError(nameof(sender) + " || " + nameof(args));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OldTab = e.TabPage;
|
OldTab = args.TabPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainForm_Shown(object sender, EventArgs e) {
|
private void MainForm_Shown(object sender, EventArgs args) {
|
||||||
if ((sender == null) || (e == null)) {
|
if ((sender == null) || (args == null)) {
|
||||||
|
Logging.LogNullError(nameof(sender) + " || " + nameof(args));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tutorial.OnAction(Tutorial.EPhase.Shown);
|
Tutorial.OnAction(Tutorial.EPhase.Shown);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainForm_HelpButtonClicked(object sender, CancelEventArgs e) {
|
private void MainForm_HelpButtonClicked(object sender, CancelEventArgs args) {
|
||||||
if ((sender == null) || (e == null)) {
|
if ((sender == null) || (args == null)) {
|
||||||
|
Logging.LogNullError(nameof(sender) + " || " + nameof(args));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
e.Cancel = true;
|
args.Cancel = true;
|
||||||
Tutorial.OnAction(Tutorial.EPhase.Help);
|
Tutorial.OnAction(Tutorial.EPhase.Help);
|
||||||
Process.Start("https://github.com/JustArchi/ArchiSteamFarm/wiki/Configuration");
|
Process.Start("https://github.com/JustArchi/ArchiSteamFarm/wiki/Configuration");
|
||||||
Tutorial.OnAction(Tutorial.EPhase.HelpFinished);
|
Tutorial.OnAction(Tutorial.EPhase.HelpFinished);
|
||||||
|
|||||||
@@ -84,7 +84,8 @@ namespace ConfigGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) {
|
private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) {
|
||||||
if ((sender == null) || (args == null)) {
|
if ((sender == null) || (args == null) || (args.ExceptionObject == null)) {
|
||||||
|
Logging.LogNullError(nameof(sender) + " || " + nameof(args) + " || " + nameof(args.ExceptionObject));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +93,8 @@ namespace ConfigGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs args) {
|
private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs args) {
|
||||||
if ((sender == null) || (args == null)) {
|
if ((sender == null) || (args == null) || (args.Exception == null)) {
|
||||||
|
Logging.LogNullError(nameof(sender) + " || " + nameof(args) + " || " + nameof(args.Exception));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user