mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-16 08:25:28 +00:00
Add family sharing inactivity timer
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FINALLY_ON_NEW_LINE/@EntryValue">False</s:Boolean>
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FINALLY_ON_NEW_LINE/@EntryValue">False</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ACCESSOR_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ACCESSOR_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SIMPLE_EMBEDDED_STATEMENT_STYLE/@EntryValue">LINE_BREAK</s:String>
|
||||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHING_EMPTY_BRACES/@EntryValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHING_EMPTY_BRACES/@EntryValue">True</s:Boolean>
|
||||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/TYPE_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/TYPE_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
|
||||||
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LIMIT/@EntryValue">255</s:Int64>
|
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LIMIT/@EntryValue">255</s:Int64>
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ using SteamKit2.Discovery;
|
|||||||
namespace ArchiSteamFarm {
|
namespace ArchiSteamFarm {
|
||||||
internal sealed class Bot : IDisposable {
|
internal sealed class Bot : IDisposable {
|
||||||
private const ushort CallbackSleep = 500; // In miliseconds
|
private const ushort CallbackSleep = 500; // In miliseconds
|
||||||
|
private const byte FamilySharingInactivityMinutes = 5;
|
||||||
private const uint LoginID = 0; // This must be the same for all ASF bots and all ASF processes
|
private const uint LoginID = 0; // This must be the same for all ASF bots and all ASF processes
|
||||||
private const ushort MaxSteamMessageLength = 2048;
|
private const ushort MaxSteamMessageLength = 2048;
|
||||||
|
|
||||||
@@ -81,6 +82,7 @@ namespace ArchiSteamFarm {
|
|||||||
private bool FirstTradeSent, LibraryLocked, PlayingBlocked, SkipFirstShutdown;
|
private bool FirstTradeSent, LibraryLocked, PlayingBlocked, SkipFirstShutdown;
|
||||||
private string AuthCode, TwoFactorCode;
|
private string AuthCode, TwoFactorCode;
|
||||||
private EResult LastLogOnResult;
|
private EResult LastLogOnResult;
|
||||||
|
private Timer FamilySharingInactivityTimer;
|
||||||
|
|
||||||
internal static string GetAPIStatus() {
|
internal static string GetAPIStatus() {
|
||||||
var response = new {
|
var response = new {
|
||||||
@@ -286,6 +288,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
// Those are objects that might be null and the check should be in-place
|
// Those are objects that might be null and the check should be in-place
|
||||||
AcceptConfirmationsTimer?.Dispose();
|
AcceptConfirmationsTimer?.Dispose();
|
||||||
|
FamilySharingInactivityTimer?.Dispose();
|
||||||
SendItemsTimer?.Dispose();
|
SendItemsTimer?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,6 +592,7 @@ namespace ArchiSteamFarm {
|
|||||||
private void CheckOccupationStatus() {
|
private void CheckOccupationStatus() {
|
||||||
if (!IsFarmingPossible) {
|
if (!IsFarmingPossible) {
|
||||||
Logging.LogGenericInfo("Account is currently being used, ASF will resume farming when it's free...", BotName);
|
Logging.LogGenericInfo("Account is currently being used, ASF will resume farming when it's free...", BotName);
|
||||||
|
StopFamilySharingInactivityTimer();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,6 +600,38 @@ namespace ArchiSteamFarm {
|
|||||||
CardsFarmer.Resume();
|
CardsFarmer.Resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CheckFamilySharingInactivity() {
|
||||||
|
if (!IsFarmingPossible) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.LogGenericInfo("Shared library has not been launched in given time period, farming process resumed!", BotName);
|
||||||
|
CardsFarmer.Resume();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StartFamilySharingInactivityTimer() {
|
||||||
|
if (FamilySharingInactivityTimer != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FamilySharingInactivityTimer = new Timer(
|
||||||
|
e => CheckFamilySharingInactivity(),
|
||||||
|
null,
|
||||||
|
TimeSpan.FromMinutes(FamilySharingInactivityMinutes), // Delay
|
||||||
|
Timeout.InfiniteTimeSpan // Period
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StopFamilySharingInactivityTimer() {
|
||||||
|
if (FamilySharingInactivityTimer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FamilySharingInactivityTimer.Change(Timeout.Infinite, Timeout.Infinite);
|
||||||
|
FamilySharingInactivityTimer.Dispose();
|
||||||
|
FamilySharingInactivityTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task InitializeFamilySharing() {
|
private async Task InitializeFamilySharing() {
|
||||||
HashSet<ulong> steamIDs = await ArchiWebHandler.GetFamilySharingSteamIDs().ConfigureAwait(false);
|
HashSet<ulong> steamIDs = await ArchiWebHandler.GetFamilySharingSteamIDs().ConfigureAwait(false);
|
||||||
if (steamIDs == null || steamIDs.Count == 0) {
|
if (steamIDs == null || steamIDs.Count == 0) {
|
||||||
@@ -699,13 +735,20 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await CardsFarmer.Pause().ConfigureAwait(false);
|
await CardsFarmer.Pause().ConfigureAwait(false);
|
||||||
return "Automatic farming is now paused!";
|
|
||||||
|
if (!SteamFamilySharingIDs.Contains(steamID)) {
|
||||||
|
return "Automatic farming is now paused!";
|
||||||
|
}
|
||||||
|
|
||||||
|
StartFamilySharingInactivityTimer();
|
||||||
|
return "Automatic farming is now paused! You have " + FamilySharingInactivityMinutes + " minutes to start a game.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CardsFarmer.Paused) {
|
if (!CardsFarmer.Paused) {
|
||||||
return "Automatic farming is resumed already!";
|
return "Automatic farming is resumed already!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StopFamilySharingInactivityTimer();
|
||||||
CardsFarmer.Resume();
|
CardsFarmer.Resume();
|
||||||
return "Automatic farming is now resumed!";
|
return "Automatic farming is now resumed!";
|
||||||
}
|
}
|
||||||
@@ -1975,7 +2018,7 @@ namespace ArchiSteamFarm {
|
|||||||
case EResult.OK:
|
case EResult.OK:
|
||||||
Logging.LogGenericInfo("Successfully logged on!", BotName);
|
Logging.LogGenericInfo("Successfully logged on!", BotName);
|
||||||
|
|
||||||
PlayingBlocked = false; // If playing is really blocked, we'll be notified in a callback, old status doesn't matter
|
LibraryLocked = PlayingBlocked = false; // Old status for these doesn't matter, we'll be notified in callback if needed
|
||||||
|
|
||||||
if ((callback.CellID != 0) && (Program.GlobalDatabase.CellID != callback.CellID)) {
|
if ((callback.CellID != 0) && (Program.GlobalDatabase.CellID != callback.CellID)) {
|
||||||
Program.GlobalDatabase.CellID = callback.CellID;
|
Program.GlobalDatabase.CellID = callback.CellID;
|
||||||
|
|||||||
Reference in New Issue
Block a user