diff options
author | Colin Okay <cbeok@protonmail.com> | 2020-04-13 17:16:46 -0500 |
---|---|---|
committer | Colin Okay <cbeok@protonmail.com> | 2020-04-13 17:16:46 -0500 |
commit | 3f99fe15eb87c43de9c7df6514413d67099658f0 (patch) | |
tree | 6d4d858af4b93df714493c765beb1bb0f4ab5d44 | |
parent | 321b078ca5be33d2add66611c73e57c2e9b98d8b (diff) |
better giphy link matching
-rw-r--r-- | README.org | 4 | ||||
-rw-r--r-- | posterbot.lisp | 4 |
2 files changed, 5 insertions, 3 deletions
@@ -39,7 +39,9 @@ git clone https://github.com/cbeo/granolin granolin - Invite the bot to a room, it should automatically accept your invitation. -- Post a link to an image. The link should end in one of =.gif=, =.jpg=, =.bmp=, =.jpeg=, or =.png=. +- Post a link to an image. The link should end in one of =.gif=, + =.jpg=, =.bmp=, =.jpeg=, or =.png=. Likes to giphy also result in a + posted gif, so long as the links look like =https://giphy.com/gifs/somethingsomething= diff --git a/posterbot.lisp b/posterbot.lisp index c354154..0af7d07 100644 --- a/posterbot.lisp +++ b/posterbot.lisp @@ -69,7 +69,7 @@ :case-insensitive-mode t)) (defparameter +giphy-link-regex+ - (ppcre:create-scanner "https://giphy.com/gifs/.+-([a-zA-Z0-9]+)" + (ppcre:create-scanner "https://giphy.com/gifs/([a-z0-9]+-)*([a-zA-Z0-9]+)" :case-insensitive-mode t)) (defun download-link (link) @@ -108,7 +108,7 @@ the downloaded file. If there is an error thrown at any point, returns NIL." (ppcre:scan-to-strings +giphy-link-regex+ word) (declare (ignore string)) (when (plusp (length matches)) - (format nil "https://media.giphy.com/media/~a/giphy.gif" (elt matches 0))))) + (format nil "https://media.giphy.com/media/~a/giphy.gif" (elt matches 1))))) (t nil))) (defun handle-link-candiate (word) |