diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index c31be622b..8ba4c5f5c 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -36,6 +36,7 @@ using ArchiSteamFarm.Localization; using ArchiSteamFarm.NLog; using ArchiSteamFarm.Plugins; using JetBrains.Annotations; +using Microsoft.OpenApi.Models; using Newtonsoft.Json; using SteamKit2; using SteamKit2.Unified.Internal; @@ -2194,6 +2195,32 @@ namespace ArchiSteamFarm { await Actions.AcceptGuestPasses(guestPassIDs).ConfigureAwait(false); } + private bool ShouldAckGroupChatMessage(ulong steamID) { + if (BotConfig.BotBehaviour.HasFlag(BotConfig.EBotBehaviour.MarkReceivedMessagesAsRead)) { + return true; + } + + if (BotConfig.BotBehaviour.HasFlag(BotConfig.EBotBehaviour.MarkBotMessagesAsRead) && + Bots.Values.Any(bot => bot.SteamID == steamID)) { + return true; + } + + return false; + } + + private bool ShouldAckPrivateChatMessage(ulong steamID, string message) { + if (ShouldAckGroupChatMessage(steamID)) { + return true; + } + + if (BotConfig.BotBehaviour.HasFlag(BotConfig.EBotBehaviour.MarkTradeMessagesAsRead) && + message.StartsWith("[tradeoffer", StringComparison.Ordinal)) { + return true; + } + + return false; + } + private async Task OnIncomingChatMessage(CChatRoom_IncomingChatMessage_Notification notification) { if (notification == null) { ArchiLogger.LogNullError(nameof(notification)); @@ -2202,8 +2229,10 @@ namespace ArchiSteamFarm { } // Under normal circumstances, timestamp must always be greater than 0, but Steam already proved that it's capable of going against the logic - if ((notification.steamid_sender != SteamID) && (notification.timestamp > 0) && BotConfig.BotBehaviour.HasFlag(BotConfig.EBotBehaviour.MarkReceivedMessagesAsRead)) { - Utilities.InBackground(() => ArchiHandler.AckChatMessage(notification.chat_group_id, notification.chat_id, notification.timestamp)); + if ((notification.steamid_sender != SteamID) && (notification.timestamp > 0)) { + if (ShouldAckGroupChatMessage(notification.steamid_sender)) { + Utilities.InBackground(() => ArchiHandler.AckChatMessage(notification.chat_group_id, notification.chat_id, notification.timestamp)); + } } string message; @@ -2242,8 +2271,10 @@ namespace ArchiSteamFarm { } // Under normal circumstances, timestamp must always be greater than 0, but Steam already proved that it's capable of going against the logic - if (!notification.local_echo && (notification.rtime32_server_timestamp > 0) && BotConfig.BotBehaviour.HasFlag(BotConfig.EBotBehaviour.MarkReceivedMessagesAsRead)) { - Utilities.InBackground(() => ArchiHandler.AckMessage(notification.steamid_friend, notification.rtime32_server_timestamp)); + if (!notification.local_echo && (notification.rtime32_server_timestamp > 0)) { + if (ShouldAckPrivateChatMessage(notification.steamid_friend, notification.message)) { + Utilities.InBackground(() => ArchiHandler.AckMessage(notification.steamid_friend, notification.rtime32_server_timestamp)); + } } string message; diff --git a/ArchiSteamFarm/BotConfig.cs b/ArchiSteamFarm/BotConfig.cs index 68b3643cb..dadfe7dc9 100644 --- a/ArchiSteamFarm/BotConfig.cs +++ b/ArchiSteamFarm/BotConfig.cs @@ -386,7 +386,9 @@ namespace ArchiSteamFarm { RejectInvalidGroupInvites = 4, DismissInventoryNotifications = 8, MarkReceivedMessagesAsRead = 16, - All = RejectInvalidFriendInvites | RejectInvalidTrades | RejectInvalidGroupInvites | DismissInventoryNotifications | MarkReceivedMessagesAsRead + MarkBotMessagesAsRead = 32, + MarkTradeMessagesAsRead = 64, + All = RejectInvalidFriendInvites | RejectInvalidTrades | RejectInvalidGroupInvites | DismissInventoryNotifications | MarkReceivedMessagesAsRead | MarkBotMessagesAsRead | MarkTradeMessagesAsRead } public enum EFarmingOrder : byte {