Compare commits

...

54 Commits

Author SHA1 Message Date
JustArchi
1a4d941a2c Fix derp, #141 2016-03-07 16:40:34 +01:00
JustArchi
cfbd880995 Add more support for SDA 2016-03-07 15:53:46 +01:00
JustArchi
09abe77495 Support SDA files 2016-03-07 15:42:38 +01:00
JustArchi
ac9943ff94 Misc 2016-03-07 14:48:59 +01:00
JustArchi
741dd2adb7 Add Holiday Sale 2013 to blacklist 2016-03-07 14:47:28 +01:00
JustArchi
1ad5d3676f Add GlobalDatabase 2016-03-07 02:39:55 +01:00
JustArchi
27254aa31e Copy ASF.json to out 2016-03-06 23:34:46 +01:00
JustArchi
bb90dc1c01 Bugfixes 2016-03-06 23:32:17 +01:00
JustArchi
292ec97b1c Work on GlobalConfig, #131 2016-03-06 23:28:56 +01:00
JustArchi
238cc2ad46 Code review 2016-03-06 22:14:02 +01:00
JustArchi
b9064bbfda Fix awaiting null tasks, closes #128 2016-03-06 21:49:34 +01:00
Łukasz Domeradzki
eddcc2816a Update README.md 2016-03-06 21:17:21 +01:00
JustArchi
52360a682a Add DismissInventoryNotifications, closes #132 2016-03-06 14:15:59 +01:00
JustArchi
709ce6489b Add only enabled bots to collection, closes #139 2016-03-06 14:09:08 +01:00
JustArchi
220a9baa7d More bugfixes 2016-03-06 02:27:43 +01:00
JustArchi
a7f2dd99c3 Minify minimal.json as it should be 2016-03-06 02:22:19 +01:00
JustArchi
3481adb3c5 ASF: Big revolution #131 2016-03-06 02:21:03 +01:00
Łukasz Domeradzki
9f5197a426 Update README.md 2016-03-05 20:32:51 +01:00
Łukasz Domeradzki
f6a631a33a Update README.md 2016-03-05 20:14:31 +01:00
Łukasz Domeradzki
9dc04ff5a0 Update README.md 2016-03-05 19:39:39 +01:00
Łukasz Domeradzki
248d200764 Update README.md 2016-03-05 19:36:03 +01:00
JustArchi
e3d08eca3f Closes #138 2016-03-05 18:56:24 +01:00
JustArchi
dc5d2483c1 Merge branch 'master' of https://github.com/JustArchi/ArchiSteamFarm 2016-03-03 16:12:01 +01:00
JustArchi
93aacad350 Closes #135 2016-03-03 16:11:46 +01:00
Łukasz Domeradzki
1b822bee91 Update README.md 2016-03-03 03:35:10 +01:00
JustArchi
c65d6fee5a Final fix for #130 2016-02-28 21:24:50 +01:00
JustArchi
6bc715575f Add GamesPlayedWhileIdle, closes #121 2016-02-28 04:15:52 +01:00
JustArchi
335044e38a Misc 2016-02-28 03:43:01 +01:00
JustArchi
6a6232b655 Mark inventory after item drops, #130
Mark is untested yet
2016-02-28 03:40:59 +01:00
JustArchi
75ff6b4f11 Bump 2016-02-26 22:43:10 +01:00
JustArchi
9cea6e35e4 Misc 2016-02-26 22:39:03 +01:00
JustArchi
52d8dc88d2 Don't sign assemblies yet, #129
I'll sign them with stable releases manually for now
2016-02-26 22:29:01 +01:00
JustArchi
1d5a50bcca Sign the application + bump, #127 2016-02-25 03:43:13 +01:00
JustArchi
44a595c1df Code review 2016-02-24 06:20:35 +01:00
JustArchi
a528dee670 Add !rejoinchat, closes #123 2016-02-24 06:06:09 +01:00
JustArchi
b6e96d8711 Fix trading bugs 2016-02-24 05:57:30 +01:00
JustArchi
c6cc4e2c9d Misc 2016-02-23 12:58:58 +01:00
JustArchi
6974e51148 Improve SendOnFarmingFinished + increase farming interval 2016-02-22 20:18:31 +01:00
JustArchi
25da5fb650 Delay main RequestLimiter further, #115 2016-02-22 18:36:56 +01:00
JustArchi
a1e8af0660 Until Mono 4.3 stabilizes, use .NET 4.5.1 2016-02-22 18:35:27 +01:00
JustArchi
af61ad66c6 Big code review 2016-02-22 18:34:45 +01:00
JustArchi
a06af3402a Speedup 2016-02-21 22:21:17 +01:00
JustArchi
08b7f18796 Make Bot.RefreshCMs() not fatal
Works around latest nightly Mono fuckup by the way
2016-02-21 22:19:55 +01:00
JustArchi
6feb1a46cc Misc 2016-02-20 23:00:30 +01:00
JustArchi
3f8e6125d1 Misc 2016-02-20 17:07:05 +01:00
JustArchi
ff887196c3 Add some misc delay between restarts 2016-02-20 02:44:01 +01:00
JustArchi
3509b1be8c Fix rare unexpected exit 2016-02-20 02:41:43 +01:00
JustArchi
b27aa50083 Misc 2016-02-16 08:33:11 +01:00
JustArchi
45230a57ee Misc 2016-02-16 08:25:27 +01:00
JustArchi
b3e420d423 Bump to 1.6 2016-02-16 08:14:19 +01:00
JustArchi
65d9f4fbee SteamAuth sync 2016-02-16 08:11:07 +01:00
JustArchi
935e11ab2a Enhance !addlicense to multiple games, closes #108 2016-02-16 08:08:06 +01:00
JustArchi
c2cd7ca52d Make use only of trading items, closes #109 2016-02-16 07:58:01 +01:00
Łukasz Domeradzki
120691c6bf Update README.md 2016-02-13 23:41:45 +01:00
32 changed files with 1813 additions and 1518 deletions

5
.gitignore vendored
View File

@@ -4,8 +4,9 @@
# Ignore all config files, apart from ones we want to include
ArchiSteamFarm/config/*
!ArchiSteamFarm/config/example.xml
!ArchiSteamFarm/config/minimal.xml
!ArchiSteamFarm/config/ASF.json
!ArchiSteamFarm/config/example.json
!ArchiSteamFarm/config/minimal.json
# Ignore local debugging log file
ArchiSteamFarm/log.txt

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/>
</startup>
</configuration>

View File

@@ -24,8 +24,11 @@
using SteamKit2;
using SteamKit2.Internal;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Threading.Tasks;
namespace ArchiSteamFarm {
internal sealed class ArchiHandler : ClientMsgHandler {
@@ -39,36 +42,52 @@ namespace ArchiSteamFarm {
*/
internal sealed class NotificationsCallback : CallbackMsg {
internal class Notification {
internal enum ENotificationType {
internal sealed class Notification {
internal enum ENotificationType : uint {
Unknown = 0,
Trading = 1,
// Only custom below, different than ones available as user_notification_type
Items = 514
}
internal ENotificationType NotificationType { get; set; }
}
internal List<Notification> Notifications { get; private set; }
internal readonly List<Notification> Notifications;
internal NotificationsCallback(JobID jobID, CMsgClientUserNotifications msg) {
JobID = jobID;
if (msg == null) {
if (msg == null || msg.notifications == null) {
return;
}
Notifications = new List<Notification>();
Notifications = new List<Notification>(msg.notifications.Count);
foreach (var notification in msg.notifications) {
Notifications.Add(new Notification {
NotificationType = (Notification.ENotificationType) notification.user_notification_type
});
}
}
internal NotificationsCallback(JobID jobID, CMsgClientItemAnnouncements msg) {
JobID = jobID;
if (msg == null) {
return;
}
if (msg.count_new_items > 0) {
Notifications = new List<Notification>(1) {
new Notification { NotificationType = Notification.ENotificationType.Items }
};
}
}
}
internal sealed class OfflineMessageCallback : CallbackMsg {
internal uint OfflineMessages { get; private set; }
internal List<uint> Users { get; private set; }
internal readonly uint OfflineMessages;
internal readonly List<uint> Users;
internal OfflineMessageCallback(JobID jobID, CMsgClientOfflineMessageNotification msg) {
JobID = jobID;
@@ -94,10 +113,10 @@ namespace ArchiSteamFarm {
OnCooldown = 53
}
internal EResult Result { get; private set; }
internal EPurchaseResult PurchaseResult { get; private set; }
internal KeyValue ReceiptInfo { get; private set; }
internal Dictionary<uint, string> Items { get; private set; }
internal readonly EResult Result;
internal readonly EPurchaseResult PurchaseResult;
internal readonly KeyValue ReceiptInfo;
internal readonly Dictionary<uint, string> Items;
internal PurchaseResponseCallback(JobID jobID, CMsgClientPurchaseResponse msg) {
JobID = jobID;
@@ -106,21 +125,22 @@ namespace ArchiSteamFarm {
return;
}
ReceiptInfo = new KeyValue();
Items = new Dictionary<uint, string>();
Result = (EResult) msg.eresult;
PurchaseResult = (EPurchaseResult) msg.purchase_result_details;
ReceiptInfo = new KeyValue();
using (MemoryStream ms = new MemoryStream(msg.purchase_receipt_info)) {
if (!ReceiptInfo.TryReadAsBinary(ms)) {
return;
}
foreach (KeyValue lineItem in ReceiptInfo["lineitems"].Children) {
List<KeyValue> lineItems = ReceiptInfo["lineitems"].Children;
Items = new Dictionary<uint, string>(lineItems.Count);
foreach (KeyValue lineItem in lineItems) {
uint appID = (uint) lineItem["PackageID"].AsUnsignedLong();
string gameName = lineItem["ItemDescription"].AsString();
gameName = Utilities.UrlDecode(gameName); // Apparently steam expects client to decode sent HTML
gameName = WebUtility.UrlDecode(gameName); // Apparently steam expects client to decode sent HTML
Items.Add(appID, gameName);
}
}
@@ -180,7 +200,7 @@ namespace ArchiSteamFarm {
}
internal void PlayGames(ICollection<uint> gameIDs) {
if (!Client.IsConnected) {
if (gameIDs == null || gameIDs.Count == 0 || !Client.IsConnected) {
return;
}
@@ -198,17 +218,24 @@ namespace ArchiSteamFarm {
Client.Send(request);
}
internal AsyncJob<PurchaseResponseCallback> RedeemKey(string key) {
internal async Task<PurchaseResponseCallback> RedeemKey(string key) {
if (string.IsNullOrEmpty(key) || !Client.IsConnected) {
return null;
}
var request = new ClientMsgProtobuf<CMsgClientRegisterKey>(EMsg.ClientRegisterKey);
request.SourceJobID = Client.GetNextJobID();
var request = new ClientMsgProtobuf<CMsgClientRegisterKey>(EMsg.ClientRegisterKey) {
SourceJobID = Client.GetNextJobID()
};
request.Body.key = key;
Client.Send(request);
return new AsyncJob<PurchaseResponseCallback>(Client, request.SourceJobID);
try {
return await new AsyncJob<PurchaseResponseCallback>(Client, request.SourceJobID);
} catch (Exception e) {
Logging.LogGenericException(e);
return null;
}
}
/*
@@ -220,7 +247,7 @@ namespace ArchiSteamFarm {
*/
public sealed override void HandleMsg(IPacketMsg packetMsg) {
public override void HandleMsg(IPacketMsg packetMsg) {
if (packetMsg == null) {
return;
}
@@ -229,6 +256,9 @@ namespace ArchiSteamFarm {
case EMsg.ClientFSOfflineMessageNotification:
HandleFSOfflineMessageNotification(packetMsg);
break;
case EMsg.ClientItemAnnouncements:
HandleItemAnnouncements(packetMsg);
break;
case EMsg.ClientPurchaseResponse:
HandlePurchaseResponse(packetMsg);
break;
@@ -244,11 +274,16 @@ namespace ArchiSteamFarm {
}
var response = new ClientMsgProtobuf<CMsgClientOfflineMessageNotification>(packetMsg);
if (response == null) {
Client.PostCallback(new OfflineMessageCallback(packetMsg.TargetJobID, response.Body));
}
private void HandleItemAnnouncements(IPacketMsg packetMsg) {
if (packetMsg == null) {
return;
}
Client.PostCallback(new OfflineMessageCallback(packetMsg.TargetJobID, response.Body));
var response = new ClientMsgProtobuf<CMsgClientItemAnnouncements>(packetMsg);
Client.PostCallback(new NotificationsCallback(packetMsg.TargetJobID, response.Body));
}
private void HandlePurchaseResponse(IPacketMsg packetMsg) {
@@ -257,10 +292,6 @@ namespace ArchiSteamFarm {
}
var response = new ClientMsgProtobuf<CMsgClientPurchaseResponse>(packetMsg);
if (response == null) {
return;
}
Client.PostCallback(new PurchaseResponseCallback(packetMsg.TargetJobID, response.Body));
}
@@ -270,10 +301,6 @@ namespace ArchiSteamFarm {
}
var response = new ClientMsgProtobuf<CMsgClientUserNotifications>(packetMsg);
if (response == null) {
return;
}
Client.PostCallback(new NotificationsCallback(packetMsg.TargetJobID, response.Body));
}
}

View File

@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ArchiSteamFarm</RootNamespace>
<AssemblyName>ArchiSteamFarm</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
@@ -36,7 +36,7 @@
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<WarningLevel>3</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -60,6 +60,16 @@
<PropertyGroup>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<DelaySign>false</DelaySign>
</PropertyGroup>
<ItemGroup>
<Reference Include="HtmlAgilityPack, Version=1.4.9.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlAgilityPack.1.4.9\lib\Net45\HtmlAgilityPack.dll</HintPath>
@@ -91,9 +101,13 @@
<Compile Include="ArchiHandler.cs" />
<Compile Include="ArchiWebHandler.cs" />
<Compile Include="Bot.cs" />
<Compile Include="BotConfig.cs" />
<Compile Include="GlobalDatabase.cs" />
<Compile Include="BotDatabase.cs" />
<Compile Include="CardsFarmer.cs" />
<Compile Include="CMsgClientClanInviteAction.cs" />
<Compile Include="Debugging.cs" />
<Compile Include="GlobalConfig.cs" />
<Compile Include="Logging.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -108,6 +122,15 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="config\ASF.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="config\example.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="config\minimal.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
@@ -124,12 +147,6 @@
</ItemGroup>
<ItemGroup>
<Content Include="cirno.ico" />
<Content Include="config\example.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="config\minimal.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SteamAuth\SteamAuth.csproj">
@@ -137,6 +154,7 @@
<Name>SteamAuth</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
@@ -145,15 +163,17 @@
<PropertyGroup>
<PostBuildEvent Condition=" '$(OS)' != 'Unix' AND '$(ConfigurationName)' == 'Release' ">
mkdir "$(TargetDir)out" "$(TargetDir)out\config"
copy "$(TargetDir)config\example.xml" "$(TargetDir)out\config"
copy "$(TargetDir)config\minimal.xml" "$(TargetDir)out\config"
copy "$(TargetDir)config\ASF.json" "$(TargetDir)out\config"
copy "$(TargetDir)config\example.json" "$(TargetDir)out\config"
copy "$(TargetDir)config\minimal.json" "$(TargetDir)out\config"
"$(SolutionDir)tools\ILRepack.exe" /ndebug /internalize /parallel /targetplatform:v4 /wildcards /out:"$(TargetDir)out\ASF.exe" "$(TargetDir)$(TargetName).exe" "$(TargetDir)*.dll"
del "$(TargetDir)out\ASF.exe.config"
</PostBuildEvent>
<PostBuildEvent Condition=" '$(OS)' == 'Unix' AND '$(ConfigurationName)' == 'Release' ">
mkdir -p "$(TargetDir)out" "$(TargetDir)out/config"
cp "$(TargetDir)config/example.xml" "$(TargetDir)out/config"
cp "$(TargetDir)config/minimal.xml" "$(TargetDir)out/config"
cp "$(TargetDir)config/ASF.json" "$(TargetDir)out/config"
cp "$(TargetDir)config/example.json" "$(TargetDir)out/config"
cp "$(TargetDir)config/minimal.json" "$(TargetDir)out/config"
mono -O=all "$(SolutionDir)tools/ILRepack.exe" /ndebug /internalize /parallel /targetplatform:v4 /wildcards /out:"$(TargetDir)out/ASF.exe" "$(TargetDir)$(TargetName).exe" "$(TargetDir)*.dll"
rm "$(TargetDir)out/ASF.exe.config"
</PostBuildEvent>

View File

@@ -27,7 +27,6 @@ using HtmlAgilityPack;
using SteamKit2;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net;
using System.Net.Http;
using System.Text;
@@ -35,82 +34,29 @@ using System.Threading.Tasks;
namespace ArchiSteamFarm {
internal sealed class ArchiWebHandler {
private const int Timeout = 1000 * WebBrowser.HttpTimeout; // In miliseconds
private static int Timeout = 30 * 1000;
private readonly Bot Bot;
private readonly string ApiKey;
private readonly Dictionary<string, string> Cookie = new Dictionary<string, string>();
private readonly Dictionary<string, string> Cookie = new Dictionary<string, string>(4);
private ulong SteamID;
private string VanityURL;
// This is required because home_process request must be done on final URL
private string GetHomeProcess() {
if (!string.IsNullOrEmpty(VanityURL)) {
return "https://steamcommunity.com/id/" + VanityURL + "/home_process";
} else if (SteamID != 0) {
return "https://steamcommunity.com/profiles/" + SteamID + "/home_process";
} else {
return null;
}
internal static void Init() {
Timeout = Program.GlobalConfig.HttpTimeout * 1000;
}
private async Task UnlockParentalAccount(string parentalPin) {
if (string.IsNullOrEmpty(parentalPin) || parentalPin.Equals("0")) {
return;
}
Logging.LogGenericInfo("Unlocking parental account...", Bot.BotName);
Dictionary<string, string> data = new Dictionary<string, string>() {
{ "pin", parentalPin }
};
HttpResponseMessage response = null;
for (byte i = 0; i < WebBrowser.MaxRetries && response == null; i++) {
response = await WebBrowser.UrlPost("https://steamcommunity.com/parental/ajaxunlock", data, Cookie, "https://steamcommunity.com/").ConfigureAwait(false);
}
if (response == null) {
Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries", Bot.BotName);
return;
}
IEnumerable<string> setCookieValues;
if (!response.Headers.TryGetValues("Set-Cookie", out setCookieValues)) {
Logging.LogNullError("setCookieValues", Bot.BotName);
return;
}
foreach (string setCookieValue in setCookieValues) {
if (setCookieValue.Contains("steamparental=")) {
string setCookie = setCookieValue.Substring(setCookieValue.IndexOf("steamparental=") + 14);
setCookie = setCookie.Substring(0, setCookie.IndexOf(';'));
Cookie["steamparental"] = setCookie;
Logging.LogGenericInfo("Success!", Bot.BotName);
return;
}
}
Logging.LogGenericWarning("Failed to unlock parental account!", Bot.BotName);
}
internal ArchiWebHandler(Bot bot, string apiKey) {
internal ArchiWebHandler(Bot bot) {
Bot = bot;
if (!string.IsNullOrEmpty(apiKey) && !apiKey.Equals("null")) {
ApiKey = apiKey;
}
}
internal async Task<bool> Init(SteamClient steamClient, string webAPIUserNonce, string vanityURL, string parentalPin) {
internal async Task<bool> Init(SteamClient steamClient, string webAPIUserNonce, string parentalPin) {
if (steamClient == null || steamClient.SteamID == null || string.IsNullOrEmpty(webAPIUserNonce)) {
return false;
}
SteamID = steamClient.SteamID;
VanityURL = vanityURL;
string sessionID = Convert.ToBase64String(Encoding.UTF8.GetBytes(SteamID.ToString(CultureInfo.InvariantCulture)));
string sessionID = Convert.ToBase64String(Encoding.UTF8.GetBytes(SteamID.ToString()));
// Generate an AES session key
byte[] sessionKey = CryptoHelper.GenerateRandomBlock(32);
@@ -122,15 +68,16 @@ namespace ArchiSteamFarm {
}
// Copy our login key
byte[] loginKey = new byte[20];
byte[] loginKey = new byte[webAPIUserNonce.Length];
Array.Copy(Encoding.ASCII.GetBytes(webAPIUserNonce), loginKey, webAPIUserNonce.Length);
// AES encrypt the loginkey with our session key
byte[] cryptedLoginKey = CryptoHelper.SymmetricEncrypt(loginKey, sessionKey);
// Send the magic
KeyValue authResult;
// Do the magic
Logging.LogGenericInfo("Logging in to ISteamUserAuth...", Bot.BotName);
KeyValue authResult;
using (dynamic iSteamUserAuth = WebAPI.GetInterface("ISteamUserAuth")) {
iSteamUserAuth.Timeout = Timeout;
@@ -160,7 +107,9 @@ namespace ArchiSteamFarm {
Cookie["sessionid"] = sessionID;
Cookie["steamLogin"] = steamLogin;
Cookie["steamLoginSecure"] = steamLoginSecure;
Cookie["birthtime"] = "-473356799";
// The below is used for display purposes only
Cookie["webTradeEligibility"] = "{\"allowed\":0,\"reason\":0,\"allowed_at_time\":0,\"steamguard_required_days\":0,\"sales_this_year\":0,\"max_sales_per_year\":0,\"forms_requested\":0}";
await UnlockParentalAccount(parentalPin).ConfigureAwait(false);
return true;
@@ -189,7 +138,7 @@ namespace ArchiSteamFarm {
bool? isLoggedIn = await IsLoggedIn().ConfigureAwait(false);
if (isLoggedIn.HasValue && !isLoggedIn.Value) {
Logging.LogGenericInfo("Reconnecting because our sessionID expired!", Bot.BotName);
var restart = Task.Run(async () => await Bot.Restart().ConfigureAwait(false));
Task.Run(async () => await Bot.Restart().ConfigureAwait(false)).Forget();
return true;
}
@@ -197,12 +146,12 @@ namespace ArchiSteamFarm {
}
internal List<SteamTradeOffer> GetTradeOffers() {
if (ApiKey == null) {
if (string.IsNullOrEmpty(Bot.BotConfig.SteamApiKey)) {
return null;
}
KeyValue response = null;
using (dynamic iEconService = WebAPI.GetInterface("IEconService", ApiKey)) {
using (dynamic iEconService = WebAPI.GetInterface("IEconService", Bot.BotConfig.SteamApiKey)) {
iEconService.Timeout = Timeout;
for (byte i = 0; i < WebBrowser.MaxRetries && response == null; i++) {
@@ -228,28 +177,16 @@ namespace ArchiSteamFarm {
SteamTradeOffer tradeOffer = new SteamTradeOffer {
tradeofferid = trade["tradeofferid"].AsString(),
accountid_other = trade["accountid_other"].AsInteger(),
message = trade["message"].AsString(),
expiration_time = trade["expiration_time"].AsInteger(),
trade_offer_state = trade["trade_offer_state"].AsEnum<SteamTradeOffer.ETradeOfferState>(),
items_to_give = new List<SteamItem>(),
items_to_receive = new List<SteamItem>(),
is_our_offer = trade["is_our_offer"].AsBoolean(),
time_created = trade["time_created"].AsInteger(),
time_updated = trade["time_updated"].AsInteger(),
from_real_time_trade = trade["from_real_time_trade"].AsBoolean(),
escrow_end_date = trade["escrow_end_date"].AsInteger(),
confirmation_method = trade["confirmation_method"].AsEnum<SteamTradeOffer.ETradeOfferConfirmationMethod>()
trade_offer_state = trade["trade_offer_state"].AsEnum<SteamTradeOffer.ETradeOfferState>()
};
foreach (KeyValue item in trade["items_to_give"].Children) {
tradeOffer.items_to_give.Add(new SteamItem {
appid = item["appid"].AsString(),
contextid = item["contextid"].AsString(),
assetid = item["assetid"].AsString(),
currencyid = item["currencyid"].AsString(),
classid = item["classid"].AsString(),
instanceid = item["instanceid"].AsString(),
amount = item["amount"].AsString(),
missing = item["missing"].AsBoolean()
});
}
foreach (KeyValue item in trade["items_to_receive"].Children) {
@@ -257,11 +194,9 @@ namespace ArchiSteamFarm {
appid = item["appid"].AsString(),
contextid = item["contextid"].AsString(),
assetid = item["assetid"].AsString(),
currencyid = item["currencyid"].AsString(),
classid = item["classid"].AsString(),
instanceid = item["instanceid"].AsString(),
amount = item["amount"].AsString(),
missing = item["missing"].AsBoolean()
});
}
result.Add(tradeOffer);
@@ -282,7 +217,7 @@ namespace ArchiSteamFarm {
string request = "https://steamcommunity.com/gid/" + clanID;
Dictionary<string, string> data = new Dictionary<string, string>() {
Dictionary<string, string> data = new Dictionary<string, string>(2) {
{"sessionID", sessionID},
{"action", "join"}
};
@@ -300,36 +235,6 @@ namespace ArchiSteamFarm {
return true;
}
internal async Task<bool> LeaveClan(ulong clanID) {
if (clanID == 0) {
return false;
}
string sessionID;
if (!Cookie.TryGetValue("sessionid", out sessionID)) {
return false;
}
string request = GetHomeProcess();
Dictionary<string, string> data = new Dictionary<string, string>() {
{"sessionID", sessionID},
{"action", "leaveGroup"},
{"groupId", clanID.ToString()}
};
HttpResponseMessage response = null;
for (byte i = 0; i < WebBrowser.MaxRetries && response == null; i++) {
response = await WebBrowser.UrlPost(request, data, Cookie).ConfigureAwait(false);
}
if (response == null) {
Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries", Bot.BotName);
return false;
}
return true;
}
internal async Task<bool> AcceptTradeOffer(ulong tradeID) {
if (tradeID == 0) {
return false;
@@ -343,7 +248,7 @@ namespace ArchiSteamFarm {
string referer = "https://steamcommunity.com/tradeoffer/" + tradeID;
string request = referer + "/accept";
Dictionary<string, string> data = new Dictionary<string, string>() {
Dictionary<string, string> data = new Dictionary<string, string>(3) {
{"sessionid", sessionID},
{"serverid", "1"},
{"tradeofferid", tradeID.ToString()}
@@ -363,12 +268,12 @@ namespace ArchiSteamFarm {
}
internal bool DeclineTradeOffer(ulong tradeID) {
if (tradeID == 0 || ApiKey == null) {
if (tradeID == 0 || string.IsNullOrEmpty(Bot.BotConfig.SteamApiKey)) {
return false;
}
KeyValue response = null;
using (dynamic iEconService = WebAPI.GetInterface("IEconService", ApiKey)) {
using (dynamic iEconService = WebAPI.GetInterface("IEconService", Bot.BotConfig.SteamApiKey)) {
iEconService.Timeout = Timeout;
for (byte i = 0; i < WebBrowser.MaxRetries && response == null; i++) {
@@ -392,10 +297,10 @@ namespace ArchiSteamFarm {
return true;
}
internal async Task<List<SteamItem>> GetInventory() {
internal async Task<List<SteamItem>> GetMyTradableInventory() {
JObject jObject = null;
for (byte i = 0; i < WebBrowser.MaxRetries && jObject == null; i++) {
jObject = await WebBrowser.UrlGetToJObject("https://steamcommunity.com/my/inventory/json/753/6", Cookie).ConfigureAwait(false);
jObject = await WebBrowser.UrlGetToJObject("https://steamcommunity.com/my/inventory/json/753/6?trading=1", Cookie).ConfigureAwait(false);
}
if (jObject == null) {
@@ -403,11 +308,19 @@ namespace ArchiSteamFarm {
return null;
}
List<SteamItem> result = new List<SteamItem>();
IEnumerable<JToken> jTokens = jObject.SelectTokens("$.rgInventory.*");
if (jTokens == null) {
Logging.LogNullError("jTokens", Bot.BotName);
return null;
}
List<SteamItem> result = new List<SteamItem>();
foreach (JToken jToken in jTokens) {
result.Add(JsonConvert.DeserializeObject<SteamItem>(jToken.ToString()));
try {
result.Add(JsonConvert.DeserializeObject<SteamItem>(jToken.ToString()));
} catch (Exception e) {
Logging.LogGenericException(e, Bot.BotName);
}
}
return result;
@@ -423,7 +336,7 @@ namespace ArchiSteamFarm {
return false;
}
List<SteamTradeOfferRequest> trades = new List<SteamTradeOfferRequest>();
List<SteamTradeOfferRequest> trades = new List<SteamTradeOfferRequest>(1 + inventory.Count / Trading.MaxItemsPerTrade);
SteamTradeOfferRequest singleTrade = null;
for (ushort i = 0; i < inventory.Count; i++) {
@@ -449,7 +362,7 @@ namespace ArchiSteamFarm {
string request = referer + "/send";
foreach (SteamTradeOfferRequest trade in trades) {
Dictionary<string, string> data = new Dictionary<string, string>() {
Dictionary<string, string> data = new Dictionary<string, string>(6) {
{"sessionid", sessionID},
{"serverid", "1"},
{"partner", partnerID.ToString()},
@@ -507,5 +420,62 @@ namespace ArchiSteamFarm {
return htmlDocument;
}
internal async Task<bool> MarkInventory() {
if (SteamID == 0) {
return false;
}
HttpResponseMessage response = null;
for (byte i = 0; i < WebBrowser.MaxRetries && response == null; i++) {
response = await WebBrowser.UrlGet("https://steamcommunity.com/profiles/" + SteamID + "/inventory", Cookie).ConfigureAwait(false);
}
if (response == null) {
Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries", Bot.BotName);
return false;
}
return true;
}
private async Task UnlockParentalAccount(string parentalPin) {
if (string.IsNullOrEmpty(parentalPin) || parentalPin.Equals("0")) {
return;
}
Logging.LogGenericInfo("Unlocking parental account...", Bot.BotName);
Dictionary<string, string> data = new Dictionary<string, string>(1) {
{ "pin", parentalPin }
};
HttpResponseMessage response = null;
for (byte i = 0; i < WebBrowser.MaxRetries && response == null; i++) {
response = await WebBrowser.UrlPost("https://steamcommunity.com/parental/ajaxunlock", data, Cookie, "https://steamcommunity.com/").ConfigureAwait(false);
}
if (response == null) {
Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries", Bot.BotName);
return;
}
IEnumerable<string> setCookieValues;
if (!response.Headers.TryGetValues("Set-Cookie", out setCookieValues)) {
Logging.LogNullError("setCookieValues", Bot.BotName);
return;
}
foreach (string setCookieValue in setCookieValues) {
if (setCookieValue.Contains("steamparental=")) {
string setCookie = setCookieValue.Substring(setCookieValue.IndexOf("steamparental=") + 14);
setCookie = setCookie.Substring(0, setCookie.IndexOf(';'));
Cookie["steamparental"] = setCookie;
Logging.LogGenericInfo("Success!", Bot.BotName);
return;
}
}
Logging.LogGenericWarning("Failed to unlock parental account!", Bot.BotName);
}
}
}

File diff suppressed because it is too large Load Diff

257
ArchiSteamFarm/BotConfig.cs Normal file
View File

@@ -0,0 +1,257 @@
/*
_ _ _ ____ _ _____
/ \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
/ _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
/ ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
/_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
Copyright 2015-2016 Łukasz "JustArchi" Domeradzki
Contact: JustArchi@JustArchi.net
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
namespace ArchiSteamFarm {
internal sealed class BotConfig {
[JsonProperty(Required = Required.DisallowNull)]
internal bool Enabled { get; private set; } = false;
[JsonProperty(Required = Required.DisallowNull)]
internal bool StartOnLaunch { get; private set; } = true;
[JsonProperty]
internal string SteamLogin { get; set; } = null;
[JsonProperty]
internal string SteamPassword { get; set; } = null;
[JsonProperty]
internal string SteamParentalPIN { get; set; } = "0";
[JsonProperty]
internal string SteamApiKey { get; private set; } = null;
[JsonProperty(Required = Required.DisallowNull)]
internal ulong SteamMasterID { get; private set; } = 0;
[JsonProperty(Required = Required.DisallowNull)]
internal ulong SteamMasterClanID { get; private set; } = 0;
[JsonProperty(Required = Required.DisallowNull)]
internal bool CardDropsRestricted { get; private set; } = false;
[JsonProperty(Required = Required.DisallowNull)]
internal bool DismissInventoryNotifications { get; private set; } = true;
[JsonProperty(Required = Required.DisallowNull)]
internal bool FarmOffline { get; private set; } = false;
[JsonProperty(Required = Required.DisallowNull)]
internal bool HandleOfflineMessages { get; private set; } = false;
[JsonProperty(Required = Required.DisallowNull)]
internal bool ForwardKeysToOtherBots { get; private set; } = false;
[JsonProperty(Required = Required.DisallowNull)]
internal bool DistributeKeys { get; private set; } = false;
[JsonProperty(Required = Required.DisallowNull)]
internal bool UseAsfAsMobileAuthenticator { get; private set; } = false;
[JsonProperty(Required = Required.DisallowNull)]
internal bool ShutdownOnFarmingFinished { get; private set; } = false;
[JsonProperty(Required = Required.DisallowNull)]
internal bool SendOnFarmingFinished { get; private set; } = false;
[JsonProperty]
internal string SteamTradeToken { get; private set; } = null;
[JsonProperty(Required = Required.DisallowNull)]
internal byte SendTradePeriod { get; private set; } = 0;
[JsonProperty(Required = Required.DisallowNull)]
internal HashSet<uint> GamesPlayedWhileIdle { get; private set; } = new HashSet<uint>() { 0 };
[JsonProperty(Required = Required.DisallowNull)]
internal bool Statistics { get; private set; } = true;
internal static BotConfig Load(string path) {
if (!File.Exists(path)) {
return null;
}
BotConfig botConfig;
try {
botConfig = JsonConvert.DeserializeObject<BotConfig>(File.ReadAllText(path));
} catch (Exception e) {
Logging.LogGenericException(e);
return null;
}
return botConfig;
}
// TODO: This should be removed soon
internal static BotConfig LoadOldFormat(string path) {
if (!File.Exists(path)) {
return null;
}
BotConfig botConfig = new BotConfig();
try {
using (XmlReader reader = XmlReader.Create(path)) {
while (reader.Read()) {
if (reader.NodeType != XmlNodeType.Element) {
continue;
}
string key = reader.Name;
if (string.IsNullOrEmpty(key)) {
continue;
}
string value = reader.GetAttribute("value");
if (string.IsNullOrEmpty(value)) {
continue;
}
switch (key) {
case "Enabled":
botConfig.Enabled = bool.Parse(value);
break;
case "SteamLogin":
botConfig.SteamLogin = value;
break;
case "SteamPassword":
botConfig.SteamPassword = value;
break;
case "SteamApiKey":
botConfig.SteamApiKey = value;
break;
case "SteamTradeToken":
botConfig.SteamTradeToken = value;
break;
case "SteamParentalPIN":
botConfig.SteamParentalPIN = value;
break;
case "SteamMasterID":
botConfig.SteamMasterID = ulong.Parse(value);
break;
case "SteamMasterClanID":
botConfig.SteamMasterClanID = ulong.Parse(value);
break;
case "StartOnLaunch":
botConfig.StartOnLaunch = bool.Parse(value);
break;
case "UseAsfAsMobileAuthenticator":
botConfig.UseAsfAsMobileAuthenticator = bool.Parse(value);
break;
case "CardDropsRestricted":
botConfig.CardDropsRestricted = bool.Parse(value);
break;
case "FarmOffline":
botConfig.FarmOffline = bool.Parse(value);
break;
case "HandleOfflineMessages":
botConfig.HandleOfflineMessages = bool.Parse(value);
break;
case "ForwardKeysToOtherBots":
botConfig.ForwardKeysToOtherBots = bool.Parse(value);
break;
case "DistributeKeys":
botConfig.DistributeKeys = bool.Parse(value);
break;
case "ShutdownOnFarmingFinished":
botConfig.ShutdownOnFarmingFinished = bool.Parse(value);
break;
case "SendOnFarmingFinished":
botConfig.SendOnFarmingFinished = bool.Parse(value);
break;
case "SendTradePeriod":
botConfig.SendTradePeriod = byte.Parse(value);
break;
case "GamesPlayedWhileIdle":
botConfig.GamesPlayedWhileIdle.Clear();
foreach (string appID in value.Split(',')) {
botConfig.GamesPlayedWhileIdle.Add(uint.Parse(appID));
}
break;
case "Statistics":
botConfig.Statistics = bool.Parse(value);
break;
case "Blacklist":
case "SteamNickname":
break;
default:
Logging.LogGenericWarning("Unrecognized config value: " + key + "=" + value);
break;
}
}
}
} catch (Exception e) {
Logging.LogGenericException(e);
Logging.LogGenericError("Your config for this bot instance is invalid, it won't run!");
return null;
}
// Fixups for new format
if (botConfig.SteamLogin != null && botConfig.SteamLogin.Equals("null")) {
botConfig.SteamLogin = null;
}
if (botConfig.SteamPassword != null && botConfig.SteamPassword.Equals("null")) {
botConfig.SteamPassword = null;
}
if (botConfig.SteamApiKey != null && botConfig.SteamApiKey.Equals("null")) {
botConfig.SteamApiKey = null;
}
if (botConfig.SteamParentalPIN != null && botConfig.SteamParentalPIN.Equals("null")) {
botConfig.SteamParentalPIN = null;
}
if (botConfig.SteamTradeToken != null && botConfig.SteamTradeToken.Equals("null")) {
botConfig.SteamTradeToken = null;
}
return botConfig;
}
// This constructor is used only by deserializer
private BotConfig() { }
// TODO: This should be removed soon
internal bool Convert(string path) {
try {
File.WriteAllText(path, JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented));
} catch (Exception e) {
Logging.LogGenericException(e);
return false;
}
Logging.LogGenericWarning("Your config was converted to new ASF V2.0 format");
return true;
}
}
}

View File

@@ -0,0 +1,104 @@
/*
_ _ _ ____ _ _____
/ \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
/ _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
/ ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
/_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
Copyright 2015-2016 Łukasz "JustArchi" Domeradzki
Contact: JustArchi@JustArchi.net
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using Newtonsoft.Json;
using SteamAuth;
using System;
using System.IO;
namespace ArchiSteamFarm {
internal sealed class BotDatabase {
internal string LoginKey {
get {
return _LoginKey;
}
set {
if (_LoginKey == value) {
return;
}
_LoginKey = value;
Save();
}
}
internal SteamGuardAccount SteamGuardAccount {
get {
return _SteamGuardAccount;
}
set {
if (_SteamGuardAccount == value) {
return;
}
_SteamGuardAccount = value;
Save();
}
}
[JsonProperty(Required = Required.AllowNull)]
private string _LoginKey;
[JsonProperty(Required = Required.AllowNull)]
private SteamGuardAccount _SteamGuardAccount;
private string FilePath;
internal static BotDatabase Load(string filePath) {
if (!File.Exists(filePath)) {
return new BotDatabase(filePath);
}
BotDatabase botDatabase;
try {
botDatabase = JsonConvert.DeserializeObject<BotDatabase>(File.ReadAllText(filePath));
} catch (Exception e) {
Logging.LogGenericException(e);
return null;
}
botDatabase.FilePath = filePath;
return botDatabase;
}
// This constructor is used when creating new database
private BotDatabase(string filePath) {
FilePath = filePath;
Save();
}
// This constructor is used only by deserializer
private BotDatabase() { }
private void Save() {
lock (FilePath) {
try {
File.WriteAllText(FilePath, JsonConvert.SerializeObject(this));
} catch (Exception e) {
Logging.LogGenericException(e);
}
}
}
}
}

View File

@@ -24,12 +24,13 @@
using SteamKit2;
using SteamKit2.Internal;
using System;
using System.IO;
namespace ArchiSteamFarm {
internal sealed class CMsgClientClanInviteAction : ISteamSerializableMessage, ISteamSerializable {
internal ulong GroupID = 0;
internal bool AcceptInvite = true;
internal sealed class CMsgClientClanInviteAction : ISteamSerializableMessage {
internal ulong GroupID { get; set; } = 0;
internal bool AcceptInvite { get; set; } = true;
EMsg ISteamSerializableMessage.GetEMsg() {
return EMsg.ClientAcknowledgeClanInvite;
@@ -44,8 +45,8 @@ namespace ArchiSteamFarm {
BinaryWriter binaryWriter = new BinaryWriter(stream);
binaryWriter.Write(GroupID);
binaryWriter.Write(AcceptInvite);
} catch {
throw new IOException();
} catch (Exception e) {
Logging.LogGenericException(e);
}
}
@@ -58,8 +59,8 @@ namespace ArchiSteamFarm {
BinaryReader binaryReader = new BinaryReader(stream);
GroupID = binaryReader.ReadUInt64();
AcceptInvite = binaryReader.ReadBoolean();
} catch {
throw new IOException();
} catch (Exception e) {
Logging.LogGenericException(e);
}
}
}

View File

@@ -36,27 +36,29 @@ namespace ArchiSteamFarm {
private const byte StatusCheckSleep = 5; // In minutes, how long to wait before checking the appID again
private const ushort MaxFarmingTime = 600; // In minutes, how long ASF is allowed to farm one game in solo mode
internal readonly ConcurrentDictionary<uint, float> GamesToFarm = new ConcurrentDictionary<uint, float>();
internal readonly List<uint> CurrentGamesFarming = new List<uint>();
private readonly ManualResetEvent FarmResetEvent = new ManualResetEvent(false);
private readonly SemaphoreSlim Semaphore = new SemaphoreSlim(1);
private readonly Bot Bot;
private readonly Timer Timer;
internal readonly ConcurrentDictionary<uint, float> GamesToFarm = new ConcurrentDictionary<uint, float>();
internal readonly List<uint> CurrentGamesFarming = new List<uint>();
private bool ManualMode = false;
private bool NowFarming = false;
internal CardsFarmer(Bot bot) {
Bot = bot;
Timer = new Timer(
async e => await CheckGamesForFarming().ConfigureAwait(false),
null,
TimeSpan.FromMinutes(15), // Delay
TimeSpan.FromMinutes(15) // Period
);
if (Timer == null) {
Timer = new Timer(
async e => await CheckGamesForFarming().ConfigureAwait(false),
null,
TimeSpan.FromMinutes(15), // Delay
TimeSpan.FromMinutes(60) // Period
);
}
}
internal static List<uint> GetGamesToFarmSolo(ConcurrentDictionary<uint, float> gamesToFarm) {
@@ -98,7 +100,7 @@ namespace ArchiSteamFarm {
await StopFarming().ConfigureAwait(false);
} else {
Logging.LogGenericInfo("Now running in Automatic Farming mode", Bot.BotName);
var start = Task.Run(async () => await StartFarming().ConfigureAwait(false));
Task.Run(async () => await StartFarming().ConfigureAwait(false)).Forget();
}
return true;
@@ -118,6 +120,7 @@ namespace ArchiSteamFarm {
}
CurrentGamesFarming.Clear();
CurrentGamesFarming.TrimExcess();
foreach (uint appID in appIDs.Keys) {
CurrentGamesFarming.Add(appID);
}
@@ -138,6 +141,7 @@ namespace ArchiSteamFarm {
}
CurrentGamesFarming.Clear();
CurrentGamesFarming.TrimExcess();
CurrentGamesFarming.Add(appID);
Logging.LogGenericInfo("Now farming: " + appID, Bot.BotName);
@@ -173,8 +177,10 @@ namespace ArchiSteamFarm {
NowFarming = true;
Semaphore.Release(); // From this point we allow other calls to shut us down
bool farmedSomething = false;
// Now the algorithm used for farming depends on whether account is restricted or not
if (Bot.CardDropsRestricted) { // If we have restricted card drops, we use complex algorithm
if (Bot.BotConfig.CardDropsRestricted) { // If we have restricted card drops, we use complex algorithm
Logging.LogGenericInfo("Chosen farming algorithm: Complex", Bot.BotName);
while (GamesToFarm.Count > 0) {
List<uint> gamesToFarmSolo = GetGamesToFarmSolo(GamesToFarm);
@@ -182,8 +188,10 @@ namespace ArchiSteamFarm {
while (gamesToFarmSolo.Count > 0) {
uint appID = gamesToFarmSolo[0];
if (await FarmSolo(appID).ConfigureAwait(false)) {
farmedSomething = true;
Logging.LogGenericInfo("Done farming: " + appID, Bot.BotName);
gamesToFarmSolo.Remove(appID);
gamesToFarmSolo.TrimExcess();
} else {
NowFarming = false;
return;
@@ -191,6 +199,7 @@ namespace ArchiSteamFarm {
}
} else {
if (FarmMultiple(GamesToFarm)) {
farmedSomething = true;
Logging.LogGenericInfo("Done farming: " + string.Join(", ", GamesToFarm.Keys), Bot.BotName);
} else {
NowFarming = false;
@@ -203,6 +212,7 @@ namespace ArchiSteamFarm {
while (GamesToFarm.Count > 0) {
uint appID = GetAnyGameToFarm(GamesToFarm);
if (await FarmSolo(appID).ConfigureAwait(false)) {
farmedSomething = true;
Logging.LogGenericInfo("Done farming: " + appID, Bot.BotName);
} else {
NowFarming = false;
@@ -212,9 +222,10 @@ namespace ArchiSteamFarm {
}
CurrentGamesFarming.Clear();
CurrentGamesFarming.TrimExcess();
NowFarming = false;
Logging.LogGenericInfo("Farming finished!", Bot.BotName);
await Bot.OnFarmingFinished().ConfigureAwait(false);
await Bot.OnFarmingFinished(farmedSomething).ConfigureAwait(false);
}
internal async Task StopFarming() {
@@ -269,29 +280,29 @@ namespace ArchiSteamFarm {
// Find APPIDs we need to farm
Logging.LogGenericInfo("Checking other pages...", Bot.BotName);
List<Task> checkPagesTasks = new List<Task>();
List<Task> tasks = new List<Task>(maxPages - 1);
for (byte page = 1; page <= maxPages; page++) {
if (page == 1) {
CheckPage(htmlDocument); // Because we fetched page number 1 already
} else {
byte currentPage = page; // We need a copy of variable being passed when in for loops
checkPagesTasks.Add(Task.Run(async () => await CheckPage(currentPage).ConfigureAwait(false)));
tasks.Add(Task.Run(async () => await CheckPage(currentPage).ConfigureAwait(false)));
}
}
await Task.WhenAll(checkPagesTasks).ConfigureAwait(false);
await Task.WhenAll(tasks).ConfigureAwait(false);
if (GamesToFarm.Count == 0) {
return true;
}
// If we have restricted card drops, actually do check hours of all games that are left to farm
if (Bot.CardDropsRestricted) {
List<Task> checkHoursTasks = new List<Task>();
if (Bot.BotConfig.CardDropsRestricted) {
tasks = new List<Task>(GamesToFarm.Keys.Count);
Logging.LogGenericInfo("Checking hours...", Bot.BotName);
foreach (uint appID in GamesToFarm.Keys) {
checkHoursTasks.Add(Task.Run(async () => await CheckHours(appID).ConfigureAwait(false)));
tasks.Add(Task.Run(async () => await CheckHours(appID).ConfigureAwait(false)));
}
await Task.WhenAll(checkHoursTasks).ConfigureAwait(false);
await Task.WhenAll(tasks).ConfigureAwait(false);
}
return true;
@@ -318,7 +329,7 @@ namespace ArchiSteamFarm {
continue;
}
if (Bot.GlobalBlacklist.Contains(appID) || Bot.Blacklist.Contains(appID)) {
if (GlobalConfig.GlobalBlacklist.Contains(appID) || Program.GlobalConfig.Blacklist.Contains(appID)) {
continue;
}
@@ -376,7 +387,7 @@ namespace ArchiSteamFarm {
}
private async Task CheckGamesForFarming() {
if (NowFarming || GamesToFarm.Count > 0 || !Bot.SteamClient.IsConnected) {
if (NowFarming || ManualMode || GamesToFarm.Count > 0 || !Bot.SteamClient.IsConnected) {
return;
}
@@ -417,7 +428,7 @@ namespace ArchiSteamFarm {
keepFarming = await ShouldFarm(appID).ConfigureAwait(false);
}
Bot.ArchiHandler.PlayGames(0);
Bot.ResetGamesPlayed();
Logging.LogGenericInfo("Stopped farming: " + appID, Bot.BotName);
return success;
}
@@ -450,7 +461,7 @@ namespace ArchiSteamFarm {
maxHour += timePlayed;
}
Bot.ArchiHandler.PlayGames(0);
Bot.ResetGamesPlayed();
Logging.LogGenericInfo("Stopped farming: " + string.Join(", ", appIDs), Bot.BotName);
return success;
}

View File

@@ -30,6 +30,6 @@ namespace ArchiSteamFarm {
internal static readonly bool IsDebugBuild = false;
#endif
internal static bool IsReleaseBuild { get { return !IsDebugBuild; } }
internal static bool IsReleaseBuild => !IsDebugBuild;
}
}

View File

@@ -0,0 +1,83 @@
/*
_ _ _ ____ _ _____
/ \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
/ _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
/ ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
/_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
Copyright 2015-2016 Łukasz "JustArchi" Domeradzki
Contact: JustArchi@JustArchi.net
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using Newtonsoft.Json;
using SteamAuth;
using System;
using System.Collections.Generic;
using System.IO;
namespace ArchiSteamFarm {
internal sealed class GlobalConfig {
internal enum EUpdateChannel : byte {
Unknown,
Stable,
Experimental
}
// This is hardcoded blacklist which should not be possible to change
internal static readonly HashSet<uint> GlobalBlacklist = new HashSet<uint> { 267420, 303700, 335590, 368020, 425280 };
[JsonProperty(Required = Required.DisallowNull)]
internal bool AutoUpdates { get; private set; } = true;
[JsonProperty(Required = Required.DisallowNull)]
internal EUpdateChannel UpdateChannel { get; private set; } = GlobalConfig.EUpdateChannel.Stable;
[JsonProperty(Required = Required.DisallowNull)]
internal byte HttpTimeout { get; private set; } = 30;
[JsonProperty(Required = Required.DisallowNull)]
internal byte RequestLimiterDelay { get; private set; } = 7;
[JsonProperty(Required = Required.DisallowNull)]
internal string WCFHostname { get; private set; } = "localhost";
[JsonProperty(Required = Required.DisallowNull)]
internal ushort WCFPort { get; private set; } = 1242;
[JsonProperty(Required = Required.DisallowNull)]
internal HashSet<uint> Blacklist { get; private set; } = new HashSet<uint>(GlobalBlacklist);
internal static GlobalConfig Load() {
string filePath = Path.Combine(Program.ConfigDirectory, Program.GlobalConfigFile);
if (!File.Exists(filePath)) {
return null;
}
GlobalConfig globalConfig;
try {
globalConfig = JsonConvert.DeserializeObject<GlobalConfig>(File.ReadAllText(filePath));
} catch (Exception e) {
Logging.LogGenericException(e);
return null;
}
return globalConfig;
}
// This constructor is used only by deserializer
private GlobalConfig() { }
}
}

View File

@@ -0,0 +1,80 @@
/*
_ _ _ ____ _ _____
/ \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
/ _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
/ ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
/_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
Copyright 2015-2016 Łukasz "JustArchi" Domeradzki
Contact: JustArchi@JustArchi.net
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using Newtonsoft.Json;
using SteamAuth;
using System;
using System.IO;
namespace ArchiSteamFarm {
internal sealed class GlobalDatabase {
private static readonly string FilePath = Path.Combine(Program.ConfigDirectory, Program.GlobalDatabaseFile);
internal uint CellID {
get {
return _CellID;
}
set {
if (_CellID == value) {
return;
}
_CellID = value;
Save();
}
}
[JsonProperty(Required = Required.DisallowNull)]
private uint _CellID = 0;
internal static GlobalDatabase Load() {
if (!File.Exists(FilePath)) {
return new GlobalDatabase();
}
GlobalDatabase globalDatabase;
try {
globalDatabase = JsonConvert.DeserializeObject<GlobalDatabase>(File.ReadAllText(FilePath));
} catch (Exception e) {
Logging.LogGenericException(e);
return null;
}
return globalDatabase;
}
// This constructor is used only by deserializer
private GlobalDatabase() { }
private void Save() {
lock (FilePath) {
try {
File.WriteAllText(FilePath, JsonConvert.SerializeObject(this));
} catch (Exception e) {
Logging.LogGenericException(e);
}
}
}
}
}

View File

@@ -31,10 +31,83 @@ namespace ArchiSteamFarm {
internal static class Logging {
private static readonly object FileLock = new object();
internal static bool LogToFile { get; set; } = false;
internal static bool? LogToFile { get; set; } = null;
internal static void Init() {
File.Delete(Program.LogFile);
if (!LogToFile.HasValue) {
LogToFile = true;
}
lock (FileLock) {
try {
File.Delete(Program.LogFile);
} catch (Exception e) {
LogGenericException(e);
}
}
}
internal static void LogGenericWTF(string message, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
if (string.IsNullOrEmpty(message)) {
return;
}
Log("[!!] WTF: " + previousMethodName + "() <" + botName + "> " + message + ", WTF?");
}
internal static void LogGenericError(string message, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
if (string.IsNullOrEmpty(message)) {
return;
}
Log("[!!] ERROR: " + previousMethodName + "() <" + botName + "> " + message);
}
internal static void LogGenericException(Exception exception, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
if (exception == null) {
return;
}
Log("[!] EXCEPTION: " + previousMethodName + "() <" + botName + "> " + exception.Message);
Log("[!] StackTrace: " + exception.StackTrace);
Exception innerException = exception.InnerException;
if (innerException != null) {
LogGenericException(innerException, botName, previousMethodName);
}
}
internal static void LogGenericWarning(string message, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
if (string.IsNullOrEmpty(message)) {
return;
}
Log("[!] WARNING: " + previousMethodName + "() <" + botName + "> " + message);
}
internal static void LogGenericInfo(string message, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
if (string.IsNullOrEmpty(message)) {
return;
}
Log("[*] INFO: " + previousMethodName + "() <" + botName + "> " + message);
}
internal static void LogNullError(string nullObjectName, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
if (string.IsNullOrEmpty(nullObjectName)) {
return;
}
LogGenericError(nullObjectName + " is null!", botName, previousMethodName);
}
[Conditional("DEBUG")]
internal static void LogGenericDebug(string message, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
if (string.IsNullOrEmpty(message)) {
return;
}
Log("[#] DEBUG: " + previousMethodName + "() <" + botName + "> " + message);
}
private static void Log(string message) {
@@ -49,46 +122,17 @@ namespace ArchiSteamFarm {
Console.Write(loggedMessage);
}
if (LogToFile) {
if (LogToFile.GetValueOrDefault()) {
lock (FileLock) {
File.AppendAllText(Program.LogFile, loggedMessage);
try {
File.AppendAllText(Program.LogFile, loggedMessage);
} catch (Exception e) {
LogToFile = false;
LogGenericException(e);
LogToFile = true;
}
}
}
}
internal static void LogGenericWTF(string message, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
Log("[!!] WTF: " + previousMethodName + "() <" + botName + "> " + message + ", WTF?");
}
internal static void LogGenericError(string message, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
Log("[!!] ERROR: " + previousMethodName + "() <" + botName + "> " + message);
}
internal static void LogGenericException(Exception exception, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
Log("[!] EXCEPTION: " + previousMethodName + "() <" + botName + "> " + exception.Message);
Log("[!] StackTrace: " + exception.StackTrace);
Exception innerException = exception.InnerException;
if (innerException != null) {
LogGenericException(innerException, botName, previousMethodName);
}
}
internal static void LogGenericWarning(string message, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
Log("[!] WARNING: " + previousMethodName + "() <" + botName + "> " + message);
}
internal static void LogGenericInfo(string message, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
Log("[*] INFO: " + previousMethodName + "() <" + botName + "> " + message);
}
internal static void LogNullError(string nullObjectName, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
LogGenericError(nullObjectName + " is null!", botName, previousMethodName);
}
[Conditional("DEBUG")]
internal static void LogGenericDebug(string message, string botName = "Main", [CallerMemberName] string previousMethodName = "") {
Log("[#] DEBUG: " + previousMethodName + "() <" + botName + "> " + message);
}
}
}

View File

@@ -49,8 +49,12 @@ namespace ArchiSteamFarm {
}
private const string LatestGithubReleaseURL = "https://api.github.com/repos/JustArchi/ArchiSteamFarm/releases/latest";
internal const string ASF = "ASF";
internal const string ConfigDirectory = "config";
internal const string LogFile = "log.txt";
internal const string GlobalConfigFile = ASF + ".json";
internal const string GlobalDatabaseFile = ASF + ".db";
private static readonly object ConsoleLock = new object();
private static readonly SemaphoreSlim SteamSemaphore = new SemaphoreSlim(1);
@@ -62,10 +66,12 @@ namespace ArchiSteamFarm {
internal static readonly string Version = Assembly.GetName().Version.ToString();
private static EMode Mode;
internal static GlobalConfig GlobalConfig { get; private set; }
internal static GlobalDatabase GlobalDatabase { get; private set; }
internal static bool ConsoleIsBusy { get; private set; } = false;
private static EMode Mode = EMode.Normal;
private static async Task CheckForUpdate() {
JObject response = await WebBrowser.UrlGetToJObject(LatestGithubReleaseURL).ConfigureAwait(false);
if (response == null) {
@@ -104,10 +110,10 @@ namespace ArchiSteamFarm {
internal static async Task LimitSteamRequestsAsync() {
await SteamSemaphore.WaitAsync().ConfigureAwait(false);
var releaseLater = Task.Run(async () => {
await Utilities.SleepAsync(5000).ConfigureAwait(false); // We must add some delay to not get caught by Steam rate limiter
Task.Run(async () => {
await Utilities.SleepAsync(GlobalConfig.RequestLimiterDelay * 1000).ConfigureAwait(false);
SteamSemaphore.Release();
});
}).Forget();
}
internal static string GetUserInput(string botLogin, EUserInputType userInputType, string extraInformation = null) {
@@ -166,8 +172,23 @@ namespace ArchiSteamFarm {
}
private static void InitServices() {
Logging.Init();
GlobalConfig = GlobalConfig.Load();
if (GlobalConfig == null) {
Logging.LogGenericError("Global config could not be loaded, please make sure that ASF.db exists and is valid!");
Thread.Sleep(5000);
Exit(1);
}
GlobalDatabase = GlobalDatabase.Load();
if (GlobalDatabase == null) {
Logging.LogGenericError("Global database could not be loaded!");
Thread.Sleep(5000);
Exit(1);
}
ArchiWebHandler.Init();
WebBrowser.Init();
WCF.Init();
}
private static void ParseArgs(string[] args) {
@@ -221,7 +242,7 @@ namespace ArchiSteamFarm {
}
private static void Main(string[] args) {
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionHandler);
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
Logging.LogGenericInfo("Archi's Steam Farm, version " + Version);
Directory.SetCurrentDirectory(ExecutableDirectory);
@@ -244,11 +265,7 @@ namespace ArchiSteamFarm {
}
}
// By default we're operating on normal mode
Mode = EMode.Normal;
Logging.LogToFile = true;
// But that can be overriden by arguments
// Parse args
ParseArgs(args);
// If we ran ASF as a client, we're done by now
@@ -256,7 +273,8 @@ namespace ArchiSteamFarm {
return;
}
Task.Run(async () => await CheckForUpdate().ConfigureAwait(false)).Wait();
// From now on it's server mode
Logging.Init();
if (!Directory.Exists(ConfigDirectory)) {
Logging.LogGenericError("Config directory doesn't exist!");
@@ -264,17 +282,34 @@ namespace ArchiSteamFarm {
Exit(1);
}
// Before attempting to connect, initialize our list of CMs
Bot.RefreshCMs();
Task.Run(async () => await CheckForUpdate().ConfigureAwait(false)).Wait();
foreach (var configFile in Directory.EnumerateFiles(ConfigDirectory, "*.xml")) {
// Before attempting to connect, initialize our list of CMs
Bot.RefreshCMs(GlobalDatabase.CellID).Wait();
foreach (var configFile in Directory.EnumerateFiles(ConfigDirectory, "*.json")) {
string botName = Path.GetFileNameWithoutExtension(configFile);
if (botName.Equals(ASF)) {
continue;
}
Bot bot = new Bot(botName);
if (!bot.Enabled) {
if (!bot.BotConfig.Enabled) {
Logging.LogGenericInfo("Not starting this instance because it's disabled in config file", botName);
}
}
// CONVERSION START
foreach (var configFile in Directory.EnumerateFiles(ConfigDirectory, "*.xml")) {
string botName = Path.GetFileNameWithoutExtension(configFile);
Logging.LogGenericWarning("Found legacy " + botName + ".xml config file, it will now be converted to new ASF V2.0 format!");
Bot bot = new Bot(botName);
if (!bot.BotConfig.Enabled) {
Logging.LogGenericInfo("Not starting this instance because it's disabled in config file", botName);
}
}
// CONVERSION END
// Check if we got any bots running
OnBotShutdown();

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.0.0")]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]

View File

@@ -28,37 +28,28 @@ namespace ArchiSteamFarm {
internal sealed class SteamItem {
// REF: https://developer.valvesoftware.com/wiki/Steam_Web_API/IEconService#CEcon_Asset
[JsonProperty]
[JsonProperty(Required = Required.DisallowNull)]
internal string appid { get; set; }
[JsonProperty]
[JsonProperty(Required = Required.DisallowNull)]
internal string contextid { get; set; }
[JsonProperty]
[JsonProperty(Required = Required.DisallowNull)]
internal string assetid { get; set; }
[JsonProperty]
[JsonProperty(Required = Required.DisallowNull)]
internal string id {
get { return assetid; }
set { assetid = value; }
}
[JsonProperty]
internal string currencyid { get; set; }
[JsonProperty]
[JsonProperty(Required = Required.AllowNull)]
internal string classid { get; set; }
[JsonProperty]
[JsonProperty(Required = Required.AllowNull)]
internal string instanceid { get; set; }
[JsonProperty]
[JsonProperty(Required = Required.Always)]
internal string amount { get; set; }
[JsonProperty]
internal bool missing { get; set; }
[JsonProperty]
internal int pos { get; set; }
}
}

View File

@@ -26,14 +26,8 @@ using Newtonsoft.Json;
using System.Collections.Generic;
namespace ArchiSteamFarm {
internal class SteamItemList {
[JsonProperty]
internal List<SteamItem> assets { get; set; } = new List<SteamItem>();
[JsonProperty]
internal List<string> currency { get; set; } = new List<string>();
[JsonProperty]
internal bool ready { get; set; } = false;
internal sealed class SteamItemList {
[JsonProperty(Required = Required.Always)]
internal List<SteamItem> assets { get; } = new List<SteamItem>();
}
}

View File

@@ -29,7 +29,7 @@ using System.Collections.Generic;
namespace ArchiSteamFarm {
internal sealed class SteamTradeOffer {
// REF: https://developer.valvesoftware.com/wiki/Steam_Web_API/IEconService#CEcon_TradeOffer
internal enum ETradeOfferState {
internal enum ETradeOfferState : byte {
Unknown,
Invalid,
Active,
@@ -44,50 +44,20 @@ namespace ArchiSteamFarm {
OnHold
}
internal enum ETradeOfferConfirmationMethod {
Invalid,
Email,
MobileApp
}
[JsonProperty]
[JsonProperty(Required = Required.Always)]
internal string tradeofferid { get; set; }
[JsonProperty]
[JsonProperty(Required = Required.Always)]
internal int accountid_other { get; set; }
[JsonProperty]
internal string message { get; set; }
[JsonProperty]
internal int expiration_time { get; set; }
[JsonProperty]
[JsonProperty(Required = Required.Always)]
internal ETradeOfferState trade_offer_state { get; set; }
[JsonProperty]
internal List<SteamItem> items_to_give { get; set; } = new List<SteamItem>();
[JsonProperty(Required = Required.Always)]
internal List<SteamItem> items_to_give { get; } = new List<SteamItem>();
[JsonProperty]
internal List<SteamItem> items_to_receive { get; set; } = new List<SteamItem>();
[JsonProperty]
internal bool is_our_offer { get; set; }
[JsonProperty]
internal int time_created { get; set; }
[JsonProperty]
internal int time_updated { get; set; }
[JsonProperty]
internal bool from_real_time_trade { get; set; }
[JsonProperty]
internal int escrow_end_date { get; set; }
[JsonProperty]
internal ETradeOfferConfirmationMethod confirmation_method { get; set; }
[JsonProperty(Required = Required.Always)]
internal List<SteamItem> items_to_receive { get; } = new List<SteamItem>();
// Extra
private ulong _OtherSteamID64 = 0;

View File

@@ -25,17 +25,17 @@
using Newtonsoft.Json;
namespace ArchiSteamFarm {
internal class SteamTradeOfferRequest {
[JsonProperty]
internal bool newversion { get; set; } = true;
internal sealed class SteamTradeOfferRequest {
[JsonProperty(Required = Required.Always)]
internal bool newversion { get; } = true;
[JsonProperty]
internal int version { get; set; } = 2;
[JsonProperty(Required = Required.Always)]
internal int version { get; } = 2;
[JsonProperty]
internal SteamItemList me { get; set; } = new SteamItemList();
[JsonProperty(Required = Required.Always)]
internal SteamItemList me { get; } = new SteamItemList();
[JsonProperty]
internal SteamItemList them { get; set; } = new SteamItemList();
[JsonProperty(Required = Required.Always)]
internal SteamItemList them { get; } = new SteamItemList();
}
}

View File

@@ -39,10 +39,10 @@ namespace ArchiSteamFarm {
internal static async Task LimitInventoryRequestsAsync() {
await InventorySemaphore.WaitAsync().ConfigureAwait(false);
var releaseLater = Task.Run(async () => {
await Utilities.SleepAsync(3000).ConfigureAwait(false); // We must add some delay to not get caught by Steam rate limiter
Task.Run(async () => {
await Utilities.SleepAsync(Program.GlobalConfig.RequestLimiterDelay * 1000).ConfigureAwait(false);
InventorySemaphore.Release();
});
}).Forget();
}
internal Trading(Bot bot) {
@@ -88,7 +88,7 @@ namespace ArchiSteamFarm {
return;
}
if (tradeOffer.items_to_give.Count == 0 || tradeOffer.OtherSteamID64 == Bot.SteamMasterID) {
if (tradeOffer.items_to_give.Count == 0 || tradeOffer.OtherSteamID64 == Bot.BotConfig.SteamMasterID) {
Logging.LogGenericInfo("Accepting trade: " + tradeID, Bot.BotName);
await Bot.ArchiWebHandler.AcceptTradeOffer(tradeID).ConfigureAwait(false);
} else {

View File

@@ -22,12 +22,13 @@
*/
using System.Net;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace ArchiSteamFarm {
internal static class Utilities {
internal static void Forget(this Task task) { }
internal static async Task SleepAsync(int miliseconds) {
await Task.Delay(miliseconds).ConfigureAwait(false);
}
@@ -72,13 +73,5 @@ namespace ArchiSteamFarm {
return count;
}
internal static string UrlDecode(string message) {
if (string.IsNullOrEmpty(message)) {
return null;
}
return WebUtility.UrlDecode(message);
}
}
}

View File

@@ -33,13 +33,17 @@ namespace ArchiSteamFarm {
string HandleCommand(string input);
}
internal class WCF : IWCF {
internal sealed class WCF : IWCF {
private const string URL = "http://localhost:1242/ASF"; // 1242 = 1024 + A(65) + S(83) + F(70)
private static string URL = "http://localhost:1242/ASF";
private ServiceHost ServiceHost;
private Client Client;
internal static void Init() {
URL = "http://" + Program.GlobalConfig.WCFHostname + ":" + Program.GlobalConfig.WCFPort + "/ASF";
}
internal bool IsServerRunning() {
return ServiceHost != null;
}
@@ -118,7 +122,7 @@ namespace ArchiSteamFarm {
}
}
internal class Client : ClientBase<IWCF>, IWCF {
internal sealed class Client : ClientBase<IWCF>, IWCF {
internal Client(Binding binding, EndpointAddress address) : base(binding, address) { }
public string HandleCommand(string input) {

View File

@@ -30,29 +30,23 @@ using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace ArchiSteamFarm {
internal static class WebBrowser {
[Flags]
internal enum RequestOptions : byte {
None = 0,
FakeUserAgent = 1 << 0,
XMLHttpRequest = 1 << 1
}
private const string FakeUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36";
internal const byte HttpTimeout = 180; // In seconds, how long we can wait for server's response
internal const byte MaxConnections = 20; // Defines maximum number of connections. Be careful, as it also defines maximum number of sockets in CLOSE_WAIT state
internal const byte MaxConnections = 10; // Defines maximum number of connections per ServicePoint. Be careful, as it also defines maximum number of sockets in CLOSE_WAIT state
internal const byte MaxIdleTime = 15; // In seconds, how long socket is allowed to stay in CLOSE_WAIT state after there are no connections to it
internal const byte MaxRetries = 5; // Defines maximum number of retries, UrlRequest() does not handle retry by itself (it's app responsibility)
private static readonly string DefaultUserAgent = "ArchiSteamFarm/" + Program.Version;
private static readonly HttpClientHandler HttpClientHandler = new HttpClientHandler { UseCookies = false };
private static readonly HttpClient HttpClient = new HttpClient(HttpClientHandler) { Timeout = TimeSpan.FromSeconds(HttpTimeout) };
private static readonly HttpClient HttpClient = new HttpClient(new HttpClientHandler {
UseCookies = false
}) {
Timeout = TimeSpan.FromSeconds(30)
};
internal static void Init() {
HttpClient.Timeout = TimeSpan.FromSeconds(Program.GlobalConfig.HttpTimeout);
// Most web services expect that UserAgent is set, so we declare it globally
// Any request can override that on as-needed basis (see: RequestOptions.FakeUserAgent)
HttpClient.DefaultRequestHeaders.UserAgent.ParseAdd(DefaultUserAgent);
@@ -65,9 +59,86 @@ namespace ArchiSteamFarm {
// Don't use Expect100Continue, we're sure about our POSTs, save some TCP packets
ServicePointManager.Expect100Continue = false;
// Reuse ports if possible
// TODO: Mono doesn't support that feature yet
//ServicePointManager.ReusePort = true;
}
private static async Task<HttpResponseMessage> UrlRequest(string request, HttpMethod httpMethod, Dictionary<string, string> data = null, Dictionary<string, string> cookies = null, string referer = null, RequestOptions requestOptions = RequestOptions.None) {
internal static async Task<HttpResponseMessage> UrlGet(string request, Dictionary<string, string> cookies = null, string referer = null) {
if (string.IsNullOrEmpty(request)) {
return null;
}
return await UrlRequest(request, HttpMethod.Get, null, cookies, referer).ConfigureAwait(false);
}
internal static async Task<HttpResponseMessage> UrlPost(string request, Dictionary<string, string> data = null, Dictionary<string, string> cookies = null, string referer = null) {
if (string.IsNullOrEmpty(request)) {
return null;
}
return await UrlRequest(request, HttpMethod.Post, data, cookies, referer).ConfigureAwait(false);
}
internal static async Task<string> UrlGetToContent(string request, Dictionary<string, string> cookies, string referer = null) {
if (string.IsNullOrEmpty(request)) {
return null;
}
HttpResponseMessage httpResponse = await UrlGet(request, cookies, referer).ConfigureAwait(false);
if (httpResponse == null) {
return null;
}
HttpContent httpContent = httpResponse.Content;
if (httpContent == null) {
return null;
}
return await httpContent.ReadAsStringAsync().ConfigureAwait(false);
}
internal static async Task<HtmlDocument> UrlGetToHtmlDocument(string request, Dictionary<string, string> cookies = null, string referer = null) {
if (string.IsNullOrEmpty(request)) {
return null;
}
string content = await UrlGetToContent(request, cookies, referer).ConfigureAwait(false);
if (string.IsNullOrEmpty(content)) {
return null;
}
content = WebUtility.HtmlDecode(content);
HtmlDocument htmlDocument = new HtmlDocument();
htmlDocument.LoadHtml(content);
return htmlDocument;
}
internal static async Task<JObject> UrlGetToJObject(string request, Dictionary<string, string> cookies = null, string referer = null) {
if (string.IsNullOrEmpty(request)) {
return null;
}
string content = await UrlGetToContent(request, cookies, referer).ConfigureAwait(false);
if (string.IsNullOrEmpty(content)) {
return null;
}
JObject jObject;
try {
jObject = JObject.Parse(content);
} catch (Exception e) {
Logging.LogGenericException(e);
return null;
}
return jObject;
}
private static async Task<HttpResponseMessage> UrlRequest(string request, HttpMethod httpMethod, Dictionary<string, string> data = null, Dictionary<string, string> cookies = null, string referer = null) {
if (string.IsNullOrEmpty(request) || httpMethod == null) {
return null;
}
@@ -95,14 +166,6 @@ namespace ArchiSteamFarm {
requestMessage.Headers.Referrer = new Uri(referer);
}
if (requestOptions.HasFlag(RequestOptions.FakeUserAgent)) {
requestMessage.Headers.UserAgent.ParseAdd(FakeUserAgent);
}
if (requestOptions.HasFlag(RequestOptions.XMLHttpRequest)) {
requestMessage.Headers.Add("X-Requested-With", "XMLHttpRequest");
}
try {
responseMessage = await HttpClient.SendAsync(requestMessage).ConfigureAwait(false);
} catch { // Request failed, we don't need to know the exact reason, swallow exception
@@ -116,211 +179,5 @@ namespace ArchiSteamFarm {
return responseMessage;
}
internal static async Task<HttpResponseMessage> UrlGet(string request, Dictionary<string, string> cookies = null, string referer = null, RequestOptions requestOptions = RequestOptions.None) {
if (string.IsNullOrEmpty(request)) {
return null;
}
return await UrlRequest(request, HttpMethod.Get, null, cookies, referer, requestOptions).ConfigureAwait(false);
}
internal static async Task<HttpResponseMessage> UrlPost(string request, Dictionary<string, string> data = null, Dictionary<string, string> cookies = null, string referer = null, RequestOptions requestOptions = RequestOptions.None) {
if (string.IsNullOrEmpty(request)) {
return null;
}
return await UrlRequest(request, HttpMethod.Post, data, cookies, referer, requestOptions).ConfigureAwait(false);
}
internal static async Task<HtmlDocument> HttpResponseToHtmlDocument(HttpResponseMessage httpResponse) {
if (httpResponse == null) {
return null;
}
HttpContent httpContent = httpResponse.Content;
if (httpContent == null) {
return null;
}
string content = await httpContent.ReadAsStringAsync().ConfigureAwait(false);
if (string.IsNullOrEmpty(content)) {
return null;
}
content = WebUtility.HtmlDecode(content);
HtmlDocument htmlDocument = new HtmlDocument();
htmlDocument.LoadHtml(content);
return htmlDocument;
}
internal static async Task<string> UrlGetToContent(string request, Dictionary<string, string> cookies, string referer = null, RequestOptions requestOptions = RequestOptions.None) {
if (string.IsNullOrEmpty(request)) {
return null;
}
HttpResponseMessage httpResponse = await UrlGet(request, cookies, referer, requestOptions).ConfigureAwait(false);
if (httpResponse == null) {
return null;
}
HttpContent httpContent = httpResponse.Content;
if (httpContent == null) {
return null;
}
return await httpContent.ReadAsStringAsync().ConfigureAwait(false);
}
internal static async Task<string> UrlPostToContent(string request, Dictionary<string, string> data = null, Dictionary<string, string> cookies = null, string referer = null, RequestOptions requestOptions = RequestOptions.None) {
if (string.IsNullOrEmpty(request)) {
return null;
}
HttpResponseMessage httpResponse = await UrlPost(request, data, cookies, referer, requestOptions).ConfigureAwait(false);
if (httpResponse == null) {
return null;
}
HttpContent httpContent = httpResponse.Content;
if (httpContent == null) {
return null;
}
return await httpContent.ReadAsStringAsync().ConfigureAwait(false);
}
internal static async Task<JObject> UrlPostToJObject(string request, Dictionary<string, string> data = null, Dictionary<string, string> cookies = null, string referer = null, RequestOptions requestOptions = RequestOptions.None) {
if (string.IsNullOrEmpty(request)) {
return null;
}
string content = await UrlPostToContent(request, data, cookies, referer, requestOptions).ConfigureAwait(false);
if (string.IsNullOrEmpty(content)) {
return null;
}
JObject jObject;
try {
jObject = JObject.Parse(content);
} catch (Exception e) {
Logging.LogGenericException(e);
return null;
}
return jObject;
}
internal static async Task<HtmlDocument> UrlGetToHtmlDocument(string request, Dictionary<string, string> cookies = null, string referer = null, RequestOptions requestOptions = RequestOptions.None) {
if (string.IsNullOrEmpty(request)) {
return null;
}
HttpResponseMessage httpResponse = await UrlGet(request, cookies, referer, requestOptions).ConfigureAwait(false);
if (httpResponse == null) {
return null;
}
return await HttpResponseToHtmlDocument(httpResponse).ConfigureAwait(false);
}
internal static async Task<HtmlDocument> UrlPostToHtmlDocument(string request, Dictionary<string, string> data = null, Dictionary<string, string> cookies = null, string referer = null, RequestOptions requestOptions = RequestOptions.None) {
if (string.IsNullOrEmpty(request)) {
return null;
}
HttpResponseMessage httpResponse = await UrlPost(request, data, cookies, referer, requestOptions).ConfigureAwait(false);
if (httpResponse == null) {
return null;
}
return await HttpResponseToHtmlDocument(httpResponse).ConfigureAwait(false);
}
internal static async Task<string> UrlGetToTitle(string request, Dictionary<string, string> cookies = null, string referer = null, RequestOptions requestOptions = RequestOptions.None) {
if (string.IsNullOrEmpty(request)) {
return null;
}
HtmlDocument htmlDocument = await UrlGetToHtmlDocument(request, cookies, referer, requestOptions).ConfigureAwait(false);
if (htmlDocument == null) {
return null;
}
HtmlNode htmlNode = htmlDocument.DocumentNode.SelectSingleNode("//head/title");
if (htmlNode == null) {
return null;
}
return htmlNode.InnerText;
}
internal static async Task<JArray> UrlGetToJArray(string request, Dictionary<string, string> cookies = null, string referer = null, RequestOptions requestOptions = RequestOptions.None) {
if (string.IsNullOrEmpty(request)) {
return null;
}
string content = await UrlGetToContent(request, cookies, referer, requestOptions).ConfigureAwait(false);
if (string.IsNullOrEmpty(content)) {
return null;
}
JArray jArray;
try {
jArray = JArray.Parse(content);
} catch (Exception e) {
Logging.LogGenericException(e);
return null;
}
return jArray;
}
internal static async Task<JObject> UrlGetToJObject(string request, Dictionary<string, string> cookies = null, string referer = null, RequestOptions requestOptions = RequestOptions.None) {
if (string.IsNullOrEmpty(request)) {
return null;
}
string content = await UrlGetToContent(request, cookies, referer, requestOptions).ConfigureAwait(false);
if (string.IsNullOrEmpty(content)) {
return null;
}
JObject jObject;
try {
jObject = JObject.Parse(content);
} catch (Exception e) {
Logging.LogGenericException(e);
return null;
}
return jObject;
}
internal static async Task<XmlDocument> UrlGetToXML(string request, Dictionary<string, string> cookies = null, string referer = null, RequestOptions requestOptions = RequestOptions.None) {
if (string.IsNullOrEmpty(request)) {
return null;
}
string content = await UrlGetToContent(request, cookies, referer, requestOptions).ConfigureAwait(false);
if (string.IsNullOrEmpty(content)) {
return null;
}
XmlDocument xmlDocument = new XmlDocument();
try {
xmlDocument.LoadXml(content);
} catch (XmlException e) {
Logging.LogGenericException(e);
return null;
}
return xmlDocument;
}
}
}

View File

@@ -0,0 +1,15 @@
{
"AutoUpdates": true,
"UpdateChannel": 1,
"HttpTimeout": 30,
"RequestLimiterDelay": 7,
"WCFHostname": "localhost",
"WCFPort": 1242,
"Blacklist": [
267420,
303700,
335590,
368020,
425280
]
}

View File

@@ -0,0 +1,25 @@
{
"Enabled": false,
"StartOnLaunch": true,
"SteamLogin": null,
"SteamPassword": null,
"SteamParentalPIN": "0",
"SteamApiKey": null,
"SteamMasterID": 0,
"SteamMasterClanID": 0,
"CardDropsRestricted": false,
"DismissInventoryNotifications": true,
"FarmOffline": false,
"HandleOfflineMessages": false,
"ForwardKeysToOtherBots": false,
"DistributeKeys": false,
"UseAsfAsMobileAuthenticator": false,
"ShutdownOnFarmingFinished": false,
"SendOnFarmingFinished": false,
"SteamTradeToken": null,
"SendTradePeriod": 0,
"GamesPlayedWhileIdle": [
0
],
"Statistics": true
}

View File

@@ -1,153 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!-- This is full-fledged example config, you may be also interested in minimal.xml for bare minimum one -->
<!-- This config includes all user-switchable properties that you may want to change on per-bot basis -->
<!-- Default values used in config match default ASF values when given config property is not found -->
<!-- In other words, if given property is not defined, ASF will assume default pre-programmed value -->
<!-- Notice, if you use special characters reserved for XML, you should escape them -->
<!-- Escape table: [& - &amp;] | [" - &quot;] | [' - &apos;] | [< - &lt;] | [> - &gt;] -->
<!-- So e.g. if your SteamPassword is "foo&" you should write value="foo&amp;" -->
<!-- Type of the property is a tip for you that defines what values you can use -->
<!-- bool - Boolean value that can be only "true" or "false" -->
<!-- string - Any sequence of characters, unless stated otherwise (keep in mind escape table above), with special treatment of "null" value -->
<!-- byte - 8-bit unsigned integer, used mostly for small numbers (0-255) -->
<!-- uint - 32-bit unsigned integer, used mostly for steam appID -->
<!-- ulong - 64-bit unsigned (long) integer, used mostly for representing steamID64 -->
<!-- HashSet(uint) - Comma-separated list of unique 32-bit unsigned integers -->
<!-- Master switch to turn account on and off, set to "true" after you're done -->
<!-- This bot instance won't run unless below switch is set to "true" -->
<Enabled type="bool" value="false"/>
<!-- This is your steam login, the one you use for logging in to steam -->
<!-- You can use "null" if you wish to enter login on every startup -->
<SteamLogin type="string" value="null"/>
<!-- This is your steam password, the one you use for logging in to steam -->
<!-- You can use "null" if you wish to enter password on every startup -->
<SteamPassword type="string" value="null"/>
<!-- This is steam nickname, the one you want to use for bot. Can be anything up to 32 characters -->
<!-- You can use "null" if you wish to preserve your actual nickname, and this is what you want most likely -->
<SteamNickname type="string" value="null"/>
<!-- This is your bot's API key, get one at https://steamcommunity.com/dev/apikey while logged in as a bot, domain doesn't matter -->
<!-- Remember that each account should have unique API key generated through above link, wrong API key will make all API-based functionalities to fail -->
<!-- API key is useless for primary accounts, as they're not using trading feature, you can leave it at "null" if you're configuring a primary account -->
<!-- When at "null", it will disable all ASF API-based functionalities such as trading -->
<SteamApiKey type="string" value="null"/>
<!-- This is your parental PIN if you use steam parental functionality -->
<!-- Most likely you don't want to change it. You can use "null" if you wish to enter PIN on every startup, 0 means there is no PIN, and this is probably what you want -->
<SteamParentalPIN type="string" value="0"/>
<!-- This is steamID64 of the bot-master - you, for example "76561198006963719" -->
<!-- You can get one e.g. by logging in to http://steamrep.com/ -->
<!-- If you're configuring primary account, you can safely leave it at "0", as you're master yourself -->
<!-- When at "0", bot won't accept any commands, including steam cd-keys or trades" -->
<SteamMasterID type="ulong" value="0"/>
<!-- This is steamID64 of the master clan (group). If defined, bot will join the group and the chat automatically after logging in -->
<!-- The easiest way to get one is to check groups on your profile: http://steamcommunity.com/my/profile" -->
<!-- Then copying the URL of "Leave group" link, it will look like this: javascript:leaveGroupPrompt('103582791440160998','Archi\'s SC Farm') -->
<!-- The steamID64 we're looking for is there, in above example: "103582791440160998" -->
<!-- Remember that joining a group and the chat requires having non-restricted access to steam community, which is not always the case with alts -->
<!-- If you don't have your own farming group, most likely you don't want to change it, 0 means there is no master group defined -->
<SteamMasterClanID type="ulong" value="0"/>
<!-- This switch defines if bot should automatically start when ASF process is launched -->
<!-- Some people might want to avoid that, as they may prefer to issue "!start" command themselves -->
<!-- Most likely you want to keep this switch enabled, unless you have a reason -->
<StartOnLaunch type="bool" value="true"/>
<!-- This switch defines if you want to use built-in ASF two-factor-authentication (ASF 2FA) for this account -->
<!-- The one and only purpose for this function is automating steam logins and steam trades, so you won't need to enter 2FA codes all the time -->
<!-- This however defeats the whole purpose of two-factor-auth, and should be used on alt accounts ONLY -->
<!-- You should read full documentation, along with explanation here: https://github.com/JustArchi/ArchiSteamFarm/wiki/Escrow -->
<!-- Personally I suggest switching this to "true" ONLY for alts -->
<!-- WARNING, this option can potentially LOCK OUT YOUR ACCOUNT! If you don't fully understand this feature, DON'T USE IT! -->
<UseAsfAsMobileAuthenticator type="bool" value="false"/>
<!-- This switch defines if the account has card drops restricted -->
<!-- Restricted card drops means that the account doesn't receive any steam cards until it plays the game for at least 2 hours -->
<!-- There is no magical way to detect it by ASF, I made this option config-based switch -->
<!-- Based on our observations, it looks like most accounts that never issued a refund have non-restricted card drops, and this is what default value assumes -->
<!-- However, if you noticed that your cards never drop until you hit 2 hours played mark, consider setting it as "true" -->
<!-- Guessing "wrong" won't have any real consequences, ASF will just work in non-optimal way, and everybody wants to drop cards fast, right? -->
<!-- Based on this parameter, ASF will try to choose the most optimal cards farming algorithm for this account -->
<CardDropsRestricted type="bool" value="false"/>
<!-- This switch defines if the account should stay as "Offline" after logging in to Steam. This has several advantages and disadvantages -->
<!-- Personally I find it extremely useful for primary accounts, as your status will remain "Online" and not "In-Game" when ASF is farming -->
<!-- Thanks to that, your friends will never ask you again if you're playing or farming the game. Your status will now nicely reflect that -->
<!-- However, it's less useful for alt accounts, as you won't be able to interact with bots and check what they're doing - they'll appear as "Offline" -->
<!-- Personally I suggest switching this to "true" for primary accounts, and leaving it at "false" for alt accounts -->
<!-- Bot won't be able to receive and answer to your commands, unless you set "HandleOfflineMessages" below to "true" as well -->
<FarmOffline type="bool" value="false"/>
<!-- This switch defines if bot should handle offline messages when it sees them -->
<!-- Basically it should be used only when "FarmOffline" property above is true, so bot can handle offline messages -->
<!-- Reading offline messages will also mark them as received, therefore it should not be used if you want to keep them for later -->
<!-- Personally I suggest keeping this on "false" for primary accounts, and considering switching to "true" for alts, if "FarmOffline" above is set to true as well -->
<HandleOfflineMessages type="bool" value="false"/>
<!-- This switch defines if bot should try to forward key to the other bot in case of failing to redeem on his own account -->
<!-- This can be useful if you want to send key to your farm and you don't care which account redeems it -->
<!-- When "true", bot will try redeeming "AlreadyOwned", "BaseGameRequired", "OnCooldown" and "RegionLocked" keys on other available accounts -->
<!-- By default this option is disabled, as not everyone might want to redeem keys on other configured accounts -->
<!-- WARNING: Remember that Steam issues temporary ban on too many failed key activations (OnCooldown status) -->
<!-- Therefore, be careful when it comes to multiple keys activations, this option is supposed to help you, not make you lazy -->
<ForwardKeysToOtherBots type="bool" value="false"/>
<!-- This switch defines bot's behaviour on getting multiple keys -->
<!-- When "false", bot will try to redeem all keys on it's own account, when "true", keys will be distributed on "one bot, one key" basis -->
<!-- Keep in mind that "ForwardKeysToOtherBots" property defined above affects this switch as well -->
<!-- When "ForwardKeysToOtherBots" is "true", bot will try redeeming "AlreadyOwned", "BaseGameRequired", "OnCooldown" and "RegionLocked" keys on other available accounts -->
<!-- If "ForwardKeysToOtherBots" is set to "false", bot will keep unused keys for itself -->
<!-- By default this option is disabled, as not everyone might want to alter the multiple keys redeeming behaviour -->
<!-- Switch this to "true" only if you prefer to use "one bot, one key" behaviour, instead of default one, which is to redeem all keys only on one account -->
<DistributeKeys type="bool" value="false"/>
<!-- This switch defines if bot should disconnect once farming is finished -->
<!-- Keep in mind that when no bots are active, ASF will shutdown as well -->
<!-- You may want to disconnect the bot after he's done, if that's the case, set below to "true" -->
<!-- However, you may instead want to keep it online for the whole time, in this case, leave it at "false" -->
<!-- Even when bot is not farming anything, he'll keep checking badges from time to time, if there is anything new to farm -->
<!-- Personally I suggest leaving it at "false", unless you have a reason to close the process after all bots finished farming -->
<ShutdownOnFarmingFinished type="bool" value="false"/>
<!-- This switch defines if bot should send you all the items it farmed after farming is finished -->
<!-- Remember that in order to use this feature, SteamMasterID must be defined above -->
<!-- If SteamMasterID is not a friend of this bot, SteamTradeToken will also be needed to set below -->
<SendOnFarmingFinished type="bool" value="false"/>
<!-- This is a SteamTradeToken of SteamMasterID, which is required if bot doesn't have SteamMasterID on friend list -->
<!-- You can get the token here: http://steamcommunity.com/id/me/tradeoffers/privacy while being logged in as SteamMasterID -->
<!-- The token has 8 characters and is written in the last part of trade URL link, starting after "&token=" -->
<SteamTradeToken type="string" value="null"/>
<!-- This switch defines if bot should send you trade offer with all farmed cards on regular basis -->
<!-- This can become useful if you have lots of games to farm and you don't want to wait for all of them to be farmed -->
<!-- However, if you have many bots running, it may become a bit spammy/intrusive, so it's not enabled by default -->
<!-- Remember that there is also "SendOnFarmingFinished" switch above, which is far less intrusive and can be used instead -->
<!-- This property defines how often bot should send you a trade offer, in hours -->
<!-- For example, setting this to "24" will result in a trade offer being sent once per day (24 hours) -->
<!-- Default value of "0" disables that feature -->
<SendTradePeriod type="byte" value="0"/>
<!-- This is comma-separated list of IDs that should not be considered for farming -->
<!-- Default value includes appIDs that are wrongly appearing on the profile, e.g. Summer Sale, Winter Sale or Monster Summer Game -->
<!-- In addition to blacklist defined here, ASF also has global blacklist, which is being updated on as-needed basis, so you don't need to update this entry -->
<!-- You probably don't want to change anything here -->
<Blacklist type="HashSet(uint)" value="303700,335590,368020,425280"/>
<!-- This switch enables statistics for me - bot will join Archi's SC Farm group and chat on steam -->
<!-- Consider leaving it at "true", this way I can check how many running bots are active -->
<!-- Such information directly affects my willings to work on the project, as I can see how many users are actually using it -->
<!-- So if you want to see new versions coming up, bugs being fixed, and new features getting implemented, consider leaving it at "true" -->
<!-- You can find the group, along with all the statistics here: http://steamcommunity.com/groups/ascfarm -->
<Statistics type="bool" value="true"/>
</configuration>

View File

@@ -0,0 +1,5 @@
{
"Enabled": false,
"SteamLogin": null,
"SteamPassword": null
}

View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!-- This is minimalistic config "just to make ASF work". For full-fledged config, please take a look at example.xml -->
<!-- Full-fledged config includes some neat features such as offline farming or cards farming algorithm selection -->
<!-- ASF will use default values for missing properties, check example.xml to see all of them -->
<Enabled type="bool" value="false"/>
<SteamLogin type="string" value="null"/>
<SteamPassword type="string" value="null"/>
</configuration>

View File

@@ -1,6 +1,10 @@
ArchiSteamFarm
===================
[![Build status](https://ci.appveyor.com/api/projects/status/yi0y25nipcb1j1yj?svg=true)](https://ci.appveyor.com/project/JustArchi/archisteamfarm) [![GitHub release](https://img.shields.io/github/release/JustArchi/ArchiSteamFarm.svg)](https://github.com/JustArchi/ArchiSteamFarm/releases/latest) [![Github All Releases](https://img.shields.io/github/downloads/JustArchi/ArchiSteamFarm/total.svg)](https://github.com/JustArchi/ArchiSteamFarm/releases) [![Paypal donate](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HD2P2P3WGS5Y4) [![Steam donate](https://img.shields.io/badge/steam-donate-yellow.svg)](https://steamcommunity.com/tradeoffer/new/?partner=46697991&token=0ix2Ruv_)
---
ASF is a C# application that allows you to farm steam cards using multiple steam accounts simultaneously. Unlike idle master which works only on one account at given time, requires steam client running in background, and launches additional processes imitiating "game playing" status, ASF doesn't require any steam client running in the background, doesn't launch any additional processes and is made to handle unlimited steam accounts at once. In addition to that, it's meant to be run on servers or other desktop-less machines, and features full Mono support, which makes it possible to launch on any Mono-supported operating system, such as Windows, Linux or OS X. ASF is based on, and possible, thanks to [SteamKit2](https://github.com/SteamRE/SteamKit).
ASF doesn't require and doesn't interfere in any way with Steam client. In addition to that, it no longer requires exclusive access to given account, which means that you can use your main account in Steam client, and use ASF for farming the same account at the same time. If you decide to launch a game, ASF will get disconnected, and resume farming once you finish playing your game, being as transparent as possible.
@@ -23,16 +27,7 @@ Detailed setting up instructions are available on **[our wiki](https://github.co
**Current Commands:**
- `!2fa` Generates temporary 2FA token for current bot instance
- `!2fa <BOT>` Generates temporary 2FA token for given bot instance
- `!2faoff` Deactivates 2FA for current bot instance
- `!2faoff <BOT>` Deactivates 2FA for given bot instance
- `!exit` Stops whole ASF
- `!redeem <KEY>` Redeems cd-key on current bot instance. You can also paste cd-key directly to the chat
- `!start <BOT>` Starts given bot instance
- `!status` Prints current status of ASF
- `!stop` Stops current bot instance
- `!stop <BOT>` Stops given bot instance
Detailed documentation of all available commands is available on **[our wiki](https://github.com/JustArchi/ArchiSteamFarm/wiki/Commands)**.
> Commands can be executed via a private chat with your bot.
> Remember that bot accepts commands only from ```SteamMasterID```. That property can be configured in the config.

View File

@@ -101,8 +101,9 @@ namespace SteamAuth
public FinalizeResult FinalizeAddAuthenticator(string smsCode)
{
//The act of checking the SMS code is necessary for Steam to finalize adding the phone number to the account.
bool smsCodeGood = this._checkSMSCode(smsCode);
if (!smsCodeGood)
//Of course, we only want to check it if we're adding a phone number in the first place...
if (!String.IsNullOrEmpty(this.PhoneNumber) && !this._checkSMSCode(smsCode))
{
return FinalizeResult.BadSMSCode;
}
@@ -147,7 +148,6 @@ namespace SteamAuth
if (finalizeResponse.Response.WantMore)
{
smsCodeGood = true;
tries++;
continue;
}

View File

@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SteamAuth</RootNamespace>
<AssemblyName>SteamAuth</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>