mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-11 06:04:24 +00:00
Extra BotBehaviour options to mark as read only messages from bots, and only incoming trade offer messages (#1482)
* add MarkBotsMessagesAsRead * added MarkTradeMessagesAsRead; made MarkBotsMessagesAsRead work in group chats too * requested changes * why do you hate me so much? * requested changes
This commit is contained in:
committed by
Łukasz Domeradzki
parent
7e42808cd2
commit
60f7dc6323
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user