Add has:pin filter (#853)

Adds a new `has:*` filter. Specifically, `has:pin`.
The filter filters for messages that are pinned.
pull/854/head
Andrew Kolos 3 years ago committed by GitHub
parent 6621c10ae0
commit 20eeaa58e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,6 +19,7 @@ internal class HasMessageFilter : MessageFilter
MessageContentMatchKind.Video => message.Attachments.Any(file => file.IsVideo), MessageContentMatchKind.Video => message.Attachments.Any(file => file.IsVideo),
MessageContentMatchKind.Image => message.Attachments.Any(file => file.IsImage), MessageContentMatchKind.Image => message.Attachments.Any(file => file.IsImage),
MessageContentMatchKind.Sound => message.Attachments.Any(file => file.IsAudio), MessageContentMatchKind.Sound => message.Attachments.Any(file => file.IsAudio),
MessageContentMatchKind.Pin => message.IsPinned,
_ => throw new InvalidOperationException($"Unknown message content match kind '{_kind}'.") _ => throw new InvalidOperationException($"Unknown message content match kind '{_kind}'.")
}; };
} }

@ -7,5 +7,6 @@ internal enum MessageContentMatchKind
File, File,
Video, Video,
Image, Image,
Sound Sound,
Pin
} }

@ -58,7 +58,8 @@ internal static class FilterGrammar
Span.EqualToIgnoreCase("file").IgnoreThen(Parse.Return(MessageContentMatchKind.File)), Span.EqualToIgnoreCase("file").IgnoreThen(Parse.Return(MessageContentMatchKind.File)),
Span.EqualToIgnoreCase("video").IgnoreThen(Parse.Return(MessageContentMatchKind.Video)), Span.EqualToIgnoreCase("video").IgnoreThen(Parse.Return(MessageContentMatchKind.Video)),
Span.EqualToIgnoreCase("image").IgnoreThen(Parse.Return(MessageContentMatchKind.Image)), Span.EqualToIgnoreCase("image").IgnoreThen(Parse.Return(MessageContentMatchKind.Image)),
Span.EqualToIgnoreCase("sound").IgnoreThen(Parse.Return(MessageContentMatchKind.Sound)) Span.EqualToIgnoreCase("sound").IgnoreThen(Parse.Return(MessageContentMatchKind.Sound)),
Span.EqualToIgnoreCase("pin").IgnoreThen(Parse.Return(MessageContentMatchKind.Pin))
)) ))
.Select(k => (MessageFilter) new HasMessageFilter(k)) .Select(k => (MessageFilter) new HasMessageFilter(k))
.Named("has:<value>"); .Named("has:<value>");

Loading…
Cancel
Save