From 36e350b96e7becb897cf421057d35c5c8669f518 Mon Sep 17 00:00:00 2001 From: Rory& Date: Wed, 23 Jul 2025 09:04:54 +0200 Subject: Return less events for self-command-only mode for command listener --- .../Services/CommandListenerHostedService.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Utilities/LibMatrix.Utilities.Bot') diff --git a/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs b/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs index d0a93a4..7a5f408 100644 --- a/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs +++ b/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs @@ -41,7 +41,7 @@ public class CommandListenerHostedService( private async Task? Run(CancellationToken cancellationToken) { logger.LogInformation("Starting command listener!"); - var filter = await hs.NamedCaches.FilterCache.GetOrSetValueAsync("gay.rory.libmatrix.utilities.bot.command_listener_syncfilter.dev3" + (config.SelfCommandsOnly), + var filter = await hs.NamedCaches.FilterCache.GetOrSetValueAsync("gay.rory.libmatrix.utilities.bot.command_listener_syncfilter.dev4" + (config.SelfCommandsOnly), new SyncFilter() { AccountData = new SyncFilter.EventFilter(notTypes: ["*"], limit: 1), Presence = new SyncFilter.EventFilter(notTypes: ["*"]), @@ -49,9 +49,11 @@ public class CommandListenerHostedService( AccountData = new SyncFilter.RoomFilter.StateFilter(notTypes: ["*"]), Ephemeral = new SyncFilter.RoomFilter.StateFilter(notTypes: ["*"]), State = new SyncFilter.RoomFilter.StateFilter(notTypes: ["*"]), - Timeline = new SyncFilter.RoomFilter.StateFilter(types: ["m.room.message"], + Timeline = new SyncFilter.RoomFilter.StateFilter( + types: ["m.room.message"], notSenders: config.SelfCommandsOnly ? null : [hs.WhoAmI.UserId], - senders: config.SelfCommandsOnly ? [hs.WhoAmI.UserId] : null + senders: config.SelfCommandsOnly ? [hs.WhoAmI.UserId] : null, + limit: config.SelfCommandsOnly ? 1 : null ), } }); -- cgit 1.5.1