diff options
| author | LLLL Colonq <llll@colonq> | 2025-11-07 00:20:02 -0500 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2025-11-07 00:20:02 -0500 |
| commit | cf266a56f30daae8b9af7c9bc3267c61b1973192 (patch) | |
| tree | f365939f712973840ff19d9265c552af820cd1ef /src/wasp-model.el | |
| parent | 3d31c488fb06e9937964041f4d83d0cb1c9699ab (diff) | |
Update
Diffstat (limited to 'src/wasp-model.el')
| -rw-r--r-- | src/wasp-model.el | 65 |
1 files changed, 23 insertions, 42 deletions
diff --git a/src/wasp-model.el b/src/wasp-model.el index 80bf03b5..183eeb87 100644 --- a/src/wasp-model.el +++ b/src/wasp-model.el @@ -32,21 +32,6 @@ )) (w/pub '(avatar frame) (list (base64-encode-string data t))))) -(defun w/color-value-to-html-code (cval) - "Convert color value CVAL to an HTML color code." - (and - cval - (format - "#%02x%02x%02x" - (truncate (* 255 (/ (car cval) 65535.0))) - (truncate (* 255 (/ (cadr cval) 65535.0))) - (truncate (* 255 (/ (caddr cval) 65535.0))) - ))) - -(defun w/color-to-html-code (cname) - "Convert color name CNAME to an HTML color code." - (w/color-value-to-html-code (color-values cname))) - (defvar w/model-palette-counter nil "Time to display model changes.") (defun w/model-record-change () @@ -58,6 +43,11 @@ (interactive) (w/pub '(avatar reset)) ;; (w/model-region-video "hair" "https://www.youtube.com/watch?v=PruiY9BJi84") + (w/model-region-word "eyes" "EYES") + (w/model-region-word "hair" "hair") + (w/model-region-word "highlight" "highlight") + ;; (w/model-region-color "hat" (color-values "#FF7518")) + (w/model-region-word "hat" "ISPUMPKIN") (w/irish-reset) (w/model-get-default-backgrounds (lambda (bgs) @@ -88,20 +78,11 @@ (w/pub '(avatar text) (list encoded))))) (w/defstruct - w/color-source + w/model-color-source type ;; 'color or 'twitch-emote or '7tv-emote or 'video-url value) -(defconst w/allowed-video-sites - '("www.youtube.com" "youtube.com" "youtu.be" "www.twitch.tv" "twitch.tv" "clips.twitch.tv" "tiktok.com" "www.tiktok.com")) - -(defun w/allowed-video-url (url) - "Return non-nil if URL is a permissible video URL." - (-contains? - w/allowed-video-sites - (url-host (url-generic-parse-url url)))) - -(defun w/string-to-color-source (s k) +(defun w/model-string-to-color-source (s k) "Convert S to a color source and pass it to K." (w/twitch-get-emote s @@ -112,10 +93,10 @@ (funcall k (cond - (url (w/make-color-source :type 'video-url :value s)) - (emote (w/make-color-source :type 'twitch-emote :value emote)) - (7tv-emote (w/make-color-source :type '7tv-emote :value 7tv-emote)) - (color (w/make-color-source :type 'color :value color)) + (url (w/make-model-color-source :type 'video-url :value s)) + (emote (w/make-model-color-source :type 'twitch-emote :value emote)) + (7tv-emote (w/make-model-color-source :type '7tv-emote :value 7tv-emote)) + (color (w/make-model-color-source :type 'color :value color)) (t nil))))))) (defun w/model-region-word (type msg) @@ -160,46 +141,46 @@ (defun w/model-region-color-source (type cs) "Change the model region TYPE to CS." - (cl-case (w/color-source-type cs) + (cl-case (w/model-color-source-type cs) (color (w/model-region-color type - (w/color-source-value cs))) + (w/model-color-source-value cs))) (twitch-emote (w/model-region-image type - (w/twitch-emote-path (w/color-source-value cs)))) + (w/twitch-emote-path (w/model-color-source-value cs)))) (7tv-emote (w/model-region-image type - (w/twitch-7tv-emote-path (w/color-source-value cs)))) + (w/twitch-7tv-emote-path (w/model-color-source-value cs)))) (video-url (w/model-region-video type - (w/color-source-value cs))) + (w/model-color-source-value cs))) (t nil))) -(defun w/handle-redeem-region-swap (type) +(defun w/model-handle-redeem-region-swap (type) "Return a redeem callback for region swap of TYPE. If the color is unspecified, use DEFCOLOR." (lambda (user inp) (let ((splinp (s-split-up-to " " (s-trim inp) 1)) (auth (w/user-authorized))) - (w/string-to-color-source + (w/model-string-to-color-source (car splinp) (lambda (cs) (let ((text (if cs (cadr splinp) (s-join " " splinp)))) - (w/write-chat-event (format "%s changes my %s to %s" user type inp)) + (w/chat-write-event (format "%s changes my %s to %s" user type inp)) (when cs (if (or auth - (not (eq 'video-url (w/color-source-type cs)))) + (not (eq 'video-url (w/model-color-source-type cs)))) (w/model-region-color-source type cs) - (w/write-chat-event (format "%s is not authorized to play video, boost harder" user)))) + (w/chat-write-event (format "%s is not authorized to play video, boost harder" user)))) (when text (w/model-region-word type text)))))))) (defvar w/model-timer nil) -(defun w/run-model-timer () +(defun w/model-run-timer () "Run the model timer." (when w/model-timer (cancel-timer w/model-timer)) @@ -211,7 +192,7 @@ If the color is unspecified, use DEFCOLOR." )) (setq w/model-timer - (run-with-timer 1 nil #'w/run-model-timer))) + (run-with-timer 1 nil #'w/model-run-timer))) (defun w/test-length-prefixed (s) (let ((bytes (seq-into s 'list))) |
