mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 06:00:46 +00:00
Prepare for offline messages
This commit is contained in:
@@ -30,6 +30,14 @@ using System.IO;
|
||||
|
||||
namespace ArchiSteamFarm {
|
||||
internal sealed class ArchiHandler : ClientMsgHandler {
|
||||
internal sealed class OfflineMessageCallback : CallbackMsg {
|
||||
internal List<uint> Users;
|
||||
internal uint OfflineMessages;
|
||||
internal OfflineMessageCallback(CMsgClientOfflineMessageNotification body) {
|
||||
OfflineMessages = body.offline_messages;
|
||||
Users = body.friends_with_offline_messages;
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class PurchaseResponseCallback : CallbackMsg {
|
||||
internal enum EPurchaseResult {
|
||||
@@ -149,7 +157,8 @@ namespace ArchiSteamFarm {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Handle offline messages?
|
||||
var response = new ClientMsgProtobuf<CMsgClientOfflineMessageNotification>(packetMsg);
|
||||
Client.PostCallback(new OfflineMessageCallback(response.Body));
|
||||
}
|
||||
|
||||
private void HandlePurchaseResponse(IPacketMsg packetMsg) {
|
||||
|
||||
@@ -67,7 +67,8 @@ namespace ArchiSteamFarm {
|
||||
internal ulong SteamMasterID { get; private set; } = 0;
|
||||
internal ulong SteamMasterClanID { get; private set; } = 0;
|
||||
internal bool CardDropsRestricted { get; private set; } = false;
|
||||
internal bool FarmOnline { get; private set; } = true;
|
||||
internal bool FarmOffline { get; private set; } = false;
|
||||
internal bool HandleOfflineMessages { get; private set; } = false;
|
||||
internal bool UseAsfAsMobileAuthenticator { get; private set; } = false;
|
||||
internal bool ShutdownOnFarmingFinished { get; private set; } = false;
|
||||
internal HashSet<uint> Blacklist { get; private set; } = new HashSet<uint> { 303700, 335590, 368020, 425280 };
|
||||
@@ -151,6 +152,7 @@ namespace ArchiSteamFarm {
|
||||
CallbackManager.Subscribe<SteamUser.UpdateMachineAuthCallback>(OnMachineAuth);
|
||||
|
||||
CallbackManager.Subscribe<ArchiHandler.NotificationCallback>(OnNotification);
|
||||
CallbackManager.Subscribe<ArchiHandler.OfflineMessageCallback>(OnOfflineMessage);
|
||||
CallbackManager.Subscribe<ArchiHandler.PurchaseResponseCallback>(OnPurchaseResponse);
|
||||
|
||||
ArchiWebHandler = new ArchiWebHandler(this, SteamApiKey);
|
||||
@@ -302,10 +304,13 @@ namespace ArchiSteamFarm {
|
||||
case "CardDropsRestricted":
|
||||
CardDropsRestricted = bool.Parse(value);
|
||||
break;
|
||||
case "FarmOnline":
|
||||
FarmOnline = bool.Parse(value);
|
||||
case "FarmOffline":
|
||||
FarmOffline = bool.Parse(value);
|
||||
break;
|
||||
case "ShutdownOnFarmingFinished":
|
||||
case "HandleOfflineMessages":
|
||||
HandleOfflineMessages = bool.Parse(value);
|
||||
break;
|
||||
case "ShutdownOnFarmingFinished":
|
||||
ShutdownOnFarmingFinished = bool.Parse(value);
|
||||
break;
|
||||
case "Blacklist":
|
||||
@@ -692,7 +697,7 @@ namespace ArchiSteamFarm {
|
||||
return;
|
||||
}
|
||||
|
||||
if (FarmOnline) {
|
||||
if (!FarmOffline) {
|
||||
SteamFriends.SetPersonaState(EPersonaState.Online);
|
||||
}
|
||||
}
|
||||
@@ -855,6 +860,19 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
|
||||
private void OnOfflineMessage(ArchiHandler.OfflineMessageCallback callback) {
|
||||
if (callback == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!HandleOfflineMessages) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Enable this after SK2 1.7+ gets released
|
||||
//SteamFriends.RequestOfflineMessages();
|
||||
}
|
||||
|
||||
private async void OnPurchaseResponse(ArchiHandler.PurchaseResponseCallback callback) {
|
||||
if (callback == null) {
|
||||
return;
|
||||
|
||||
@@ -63,10 +63,16 @@
|
||||
<!-- TIP: 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 show as "Online" after logging in to Steam -->
|
||||
<!-- Please note that bot won't be able to respond to any commands when this property is "false" -->
|
||||
<!-- TIP: Setting this to "false" may be useful for primary accounts, to not show as online when you're not here -->
|
||||
<FarmOnline type="bool" value="true"/>
|
||||
<!-- This switch defines if the account should stay as "Offline" after logging in to Steam -->
|
||||
<!-- Please note that bot won't be able to respond to any commands when this property is set to "true" -->
|
||||
<!-- TIP: Setting this to "true" may be useful for primary accounts, to not show as online when you're not here -->
|
||||
<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 -->
|
||||
<!-- WARNING: This switch doesn't work yet (is false for now, but will be used in future) -->
|
||||
<HandleOfflineMessages type="bool" value="false"/>
|
||||
|
||||
<!-- This switch defines if bot should disconnect once farming is finished -->
|
||||
<!-- When no bots are active, ASF will shutdown as well -->
|
||||
|
||||
Reference in New Issue
Block a user