From 946ba4923e0ce6f996d22dbd8ea7bdf126f3a7f1 Mon Sep 17 00:00:00 2001 From: cage <cage@invalid> Date: Thu, 15 Jul 2021 21:17:24 +0200 Subject: [PATCH] - made clear source and license of the emojis; - fixed docstring (thanks op!); - prevented a crash when refresh of chats hits a network error. --- LICENSES.org | 53 +++++++++++++++++++++++++++++++++++++++++ src/emoji-matcher.lisp | 12 +++------- src/program-events.lisp | 22 +++++++++-------- 3 files changed, 68 insertions(+), 19 deletions(-) diff --git a/LICENSES.org b/LICENSES.org index 49d65c5..9110a1a 100644 --- a/LICENSES.org +++ b/LICENSES.org @@ -439,3 +439,56 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +- src/emoji-matcher.lisp + + Some code is a machine translation of tables (see the code for origin) + with this license: + + + UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE + + See Terms of Use for definitions of Unicode Inc.'s + Data Files and Software. + + NOTICE TO USER: Carefully read the following legal agreement. + BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S + DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"), + YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE + TERMS AND CONDITIONS OF THIS AGREEMENT. + IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE + THE DATA FILES OR SOFTWARE. + + COPYRIGHT AND PERMISSION NOTICE + + Copyright © 1991-2021 Unicode, Inc. All rights reserved. + Distributed under the Terms of Use in https://www.unicode.org/copyright.html. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of the Unicode data files and any associated documentation + (the "Data Files") or Unicode software and any associated documentation + (the "Software") to deal in the Data Files or Software + without restriction, including without limitation the rights to use, + copy, modify, merge, publish, distribute, and/or sell copies of + the Data Files or Software, and to permit persons to whom the Data Files + or Software are furnished to do so, provided that either + (a) this copyright and permission notice appear with all copies + of the Data Files or Software, or + (b) this copyright and permission notice appear in associated + Documentation. + + THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF + ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT OF THIRD PARTY RIGHTS. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS + NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL + DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THE DATA FILES OR SOFTWARE. + + Except as contained in this notice, the name of a copyright holder + shall not be used in advertising or otherwise to promote the sale, + use or other dealings in these Data Files or Software without prior + written authorization of the copyright holder. diff --git a/src/emoji-matcher.lisp b/src/emoji-matcher.lisp index f5e77b0..cd77f54 100644 --- a/src/emoji-matcher.lisp +++ b/src/emoji-matcher.lisp @@ -14,8 +14,7 @@ (every #'char= a b)) (defun extract-codepoints (stream) - "Extract shotcodes from the file: - https://raw.githubusercontent.com/node-unicode/node-unicode-data/master/data/11.0.0-emoji.txt" + "Extract shotcodes from the emoji table file" (flet ((readline () (read-line stream nil nil))) (let ((res ())) @@ -46,17 +45,12 @@ (defmacro gen-matcher-sequences () `(defun emoji-sequences-p (chars) (find-if (lambda (a) (match-codepoint-p chars a)) - ',(extract-emojis-codepoints "https://raw.githubusercontent.com/node-unicode/node-unicode-data/master/data/13.0.0-emoji-sequences.txt")))) + ',(extract-emojis-codepoints "https://unicode.org/Public/emoji/13.1/emoji-sequences.txt")))) (defmacro gen-matcher-zwj-sequences () `(defun emoji-zwj-sequences-p (chars) (find-if (lambda (a) (match-codepoint-p chars a)) - ',(extract-emojis-codepoints "https://raw.githubusercontent.com/node-unicode/node-unicode-data/master/data/13.0.0-emoji-zwj-sequences.txt")))) - -(defmacro gen-matcher () - `(defun emoji-simple-p (chars) - (find-if (lambda (a) (match-codepoint-p chars a)) - ',(extract-emojis-codepoints "https://raw.githubusercontent.com/node-unicode/node-unicode-data/master/data/13.0.0-emoji.txt")))) + ',(extract-emojis-codepoints "https://unicode.org/Public/emoji/13.1/emoji-zwj-sequences.txt")))) ;;;; expansion of (gen-matcher-sequences) diff --git a/src/program-events.lisp b/src/program-events.lisp index d3b869a..9582594 100644 --- a/src/program-events.lisp +++ b/src/program-events.lisp @@ -1359,20 +1359,22 @@ (defmethod process-event ((object get-chats-event)) (with-accessors ((chat-id chat-id) (min-message-id min-message-id)) object - (let ((chats (api-pleroma:get-chats))) - (dolist (chat chats) - (db:update-db chat))))) + (tui:with-notify-errors + (let ((chats (api-pleroma:get-chats))) + (dolist (chat chats) + (db:update-db chat)))))) (defclass update-all-chat-messages-event (program-event) ()) (defmethod process-event ((object update-all-chat-messages-event)) - (let ((all-chats (db:all-chats))) - (dolist (chat all-chats) - (let* ((chat-id (db:row-id chat)) - (min-id (db:last-chat-message-id chat-id))) - (process-event (make-instance 'program-events:get-chat-messages-event - :chat-id chat-id - :min-message-id min-id)))))) + (tui:with-notify-errors + (let ((all-chats (db:all-chats))) + (dolist (chat all-chats) + (let* ((chat-id (db:row-id chat)) + (min-id (db:last-chat-message-id chat-id))) + (process-event (make-instance 'program-events:get-chat-messages-event + :chat-id chat-id + :min-message-id min-id))))))) (defclass chat-show-event (program-event) ((chat