From 6463a9f09032f22c8e39ccea757b8a7054f199ba Mon Sep 17 00:00:00 2001 From: Jakob L. Kreuze Date: Sat, 11 Mar 2023 19:33:53 -0500 Subject: Guard against non-emoji reactions --- haunt/jakob/dynamic/util.scm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'haunt/jakob/dynamic/util.scm') diff --git a/haunt/jakob/dynamic/util.scm b/haunt/jakob/dynamic/util.scm index a7fd38d..92b2f25 100644 --- a/haunt/jakob/dynamic/util.scm +++ b/haunt/jakob/dynamic/util.scm @@ -82,3 +82,24 @@ If KEY does not exist in TABLE, initialize kEY to (list ITEM)" (if (hash-ref table key) (hash-set! table key (cons item (hash-ref table key))) (hash-set! table key (list item)))) + +(define (emoji? str) + "Determine if `str' is an 'acceptable' emoji character + +Acceptable is the following subset: + +- The 'Emoticons' block +- The 'Supplemental Symbols and Pictographs' block, excluding U+1F900 + through U+1F90B +- The hand symbols from the 'Miscellaneous Symbols and Pictographs' + block +- The hand symbols from the 'Dingbats' block + +Notably, U+1F946 isn't normally treated an emoji, but it is here. I +think it should be! As an American, I should be able to use pictographs +to express my God-given constitutional rights!" + (and (string str) + (= 1 (string-length str)) + (let ((codepoint (char->integer + (first (string->list str))))) + (and (>= codepoint #x1F600) (<= codepoint #x1F64F))))) -- cgit v1.3