From 75e005e81b73d8471f16dc5fad7bbdc312bdbfe7 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Sun, 26 Apr 2026 23:47:18 -0400 Subject: Update --- src/wasp-twitch.el | 240 ++++++++++++++++++++++++++++------------------------- 1 file changed, 125 insertions(+), 115 deletions(-) (limited to 'src/wasp-twitch.el') diff --git a/src/wasp-twitch.el b/src/wasp-twitch.el index d182dddf..6559a45f 100644 --- a/src/wasp-twitch.el +++ b/src/wasp-twitch.el @@ -11,9 +11,6 @@ (require 'wasp-bus-binary) (require 'wasp-chat) (require 'wasp-user) -(require 'wasp-hexamedia) -(require 'wasp-copfish) -(require 'wasp-shindaggers) (require 'wasp-hex) (require 'wasp-user-stats) @@ -161,7 +158,7 @@ (defun w/twitch-user-avatar-path (user) "Get the path to USER's avatar." - (s-concat w/twitch-avatar-cache-dir user ".png")) + (s-concat w/twitch-avatar-cache-dir (s-downcase user) ".png")) (defun w/twitch-update-title () "Get our stream title and update `w/twitch-current-stream-title'." @@ -218,7 +215,12 @@ K is called when the download is finished." (w/twitch-api-get (s-concat "/users?login=" user) (lambda (data) - (let ((url (ht-get (aref (ht-get data "data") 0) "profile_image_url"))) + (when-let* + ( (url + (-some-> data + (ht-get "data") + (w/aref 0) + (ht-get "profile_image_url")))) ;; (w/write-log (format "downloading avatar: %s %s" url path)) (make-process :name "wasp-download-avatar" @@ -266,7 +268,7 @@ K is called when the download is finished." (w/pick-random (-difference w/twitch-vip-list - '("a_tension_span" "fighting_annelids"))))) + '("a_tension_span" "fighting_annelids" "thereal6toes"))))) (w/chat-write-event (format "Randomly removed VIP from %s - autofloor" user)) (w/twitch-remove-vip user))) @@ -447,24 +449,31 @@ CALLBACK will be passed the winner when the poll concludes." 'display img 'rear-nonsticky t)))) - + (defun w/twitch-process-emote-range (er msg) "Given a string ER of form emoteid:start-end, add the emote MSG." (if (string-empty-p er) - msg - (when-let* ((er-split (s-split ":" er)) - (emoteid (car er-split)) - (range-split (s-split "-" (cadr er-split))) - (start (string-to-number (car range-split))) - (end (string-to-number (cadr range-split))) - (emotemsg (substring msg start (+ end 1))) - (path (w/twitch-emote-path emoteid))) - (w/twitch-cache-emote emotemsg emoteid) + msg + (when-let* + ( (er-split (s-split ":" er)) + (emoteid (car er-split)) + (path (w/twitch-emote-path emoteid)) + (sranges (cadr er-split)) + (ranges (s-split "," sranges))) (w/twitch-download-emote emoteid) - (let ((img (create-image path))) - (w/twitch-add-image-over img msg (+ start 1) (+ end 2)) - )))) - + (let ((cached nil)) + (--each ranges + (when-let* + ( (range-split (s-split "-" it)) + (start (string-to-number (car range-split))) + (end (string-to-number (cadr range-split))) + (emotemsg (substring msg start (+ end 1)))) + (unless cached + (w/twitch-cache-emote emotemsg emoteid) + (setf cached t)) + (let ((img (create-image path))) + (setf msg (w/twitch-add-image-over img msg (+ start 1) (+ end 2))))))) + msg))) (defun w/twitch-process-emote-ranges (ers msg) "Apply all of ERS to MSG." (--reduce-from (w/twitch-process-emote-range it acc) msg ers)) @@ -479,17 +488,17 @@ CALLBACK will be passed the winner when the poll concludes." (goto-char (line-beginning-position)) (while (not (eobp)) (let ((plist (text-properties-at (point))) - (next-change - (or (next-property-change (point) (current-buffer)) + (next-change + (or (next-property-change (point) (current-buffer)) (point-max)))) (when-let* ((plist-true plist) - (disp (plist-get plist 'display)) - (is-image (equal (car disp) 'image)) - (image-props (cdr disp)) - (image-type (plist-get image-props :type)) - (is-gif (equal image-type 'gif)) - (multi-frame (or (plist-get (cdr disp) :animate-multi-frame-data) (image-multi-frame-p disp))) - ) + (disp (plist-get plist 'display)) + (is-image (equal (car disp) 'image)) + (image-props (cdr disp)) + (image-type (plist-get image-props :type)) + (is-gif (equal image-type 'gif)) + (multi-frame (or (plist-get (cdr disp) :animate-multi-frame-data) (image-multi-frame-p disp))) + ) (let ((frame (% w/twitch-emote-frame-counter (car multi-frame)))) (image-show-frame disp frame))) (goto-char next-change)))))) @@ -500,83 +509,86 @@ CALLBACK will be passed the winner when the poll concludes." (cancel-timer w/twitch-emote-frame-timer)) (w/twitch-advance-frame-in-chat-buffer) (setq - w/twitch-emote-frame-timer - (run-with-timer 0.03 nil #'w/twitch-run-emote-frame-timer))) + w/twitch-emote-frame-timer + (run-with-timer 0.03 nil #'w/twitch-run-emote-frame-timer))) (defun w/twitch-badges-sigil (badges) "Return the sigil character BADGES for the current user." - (let* ((equity (alist-get :equity w/user-current)) - (name (s-downcase w/user-current-name)) - (max-stars (w/aoc-max-stars)) - (aoc-stars (w/aoc-lookup-stars name))) + (let* ( ;; (equity (alist-get :equity w/user-current)) + (equity 0) + ;; (name (s-downcase w/user-current-name)) + (name "") + (max-stars (w/aoc-max-stars)) + (aoc-stars (w/aoc-lookup-stars name))) (apply - #'s-concat - (-non-nil - (list - (when (and aoc-stars (>= aoc-stars max-stars)) "πŸŽ„") - (when (-contains? badges "broadcaster/1") "(it me)") - (when (-contains? badges "moderator/1") "βš”") - (when (-contains? badges "artist-badge/1") "πŸ–ŒοΈ") - (when (and equity (> equity 0)) - (cond ;; The Equity Lords - ((s-equals? name "bezelea") "β™ΏπŸ””") - ((s-equals? name "altovt") "πŸ“ˆ") - ((s-equals? name "prodzpod") "πŸŒ πŸŒŒπŸŽ‘") ;; owed 1 emote - ((s-equals? name "faeliore") "😹") - ((s-equals? name "vasher_1025") "πŸ•΄") - ((s-equals? name "leadengin") "πŸ’ˆ") - ;; ((s-equals? name "kettlestew") "") - ((s-equals? name "blazynights") "πŸ€„") - ;; ((s-equals? name "must_broke_") "") - ((s-equals? name "bvnanana") "πŸ§‰") - ((s-equals? name "venorrak") "πŸ“ΊπŸ“œ") - ;; ((s-equals? name "tf_tokyo") "") - ((s-equals? name "devts_de") "βˆƒ") - ((s-equals? name "trap_exit") (s-concat (propertize "Q" 'display (create-image (w/twitch-emote-path "emotesv2_dfc4c36ccd3b4994b8ca4f082230f053"))) "β˜ πŸ’€")) - ((s-equals? name "essento") "πŸ₯š") - ((s-equals? name "tyumici") "🀌") - ;; clone is lord ((s-equals? name "liquidcake1") "") - ;; ((s-equals? name "loufbread_") "") - ((s-equals? name "yellowberryhn") "πŸͺ΄") - ;; ((s-equals? name "maradyne_") "") ;; owed 1 - ;; ((s-equals? name "sampie159") "") - ((s-equals? name "zamielpayne") "πŸ¦‰") - ((s-equals? name "xorxavier") "🌸") - ((s-equals? name "6horntaurus") "⚰️") ;; owed 1 - ((s-equals? name "bytomancer") (propertize "Q" 'display (create-image (w/twitch-emote-path "emotesv2_beb191005b81486c8b1c823931c88387")))) - ;; ((s-equals? name "henriqmarq") "") - ;; ((s-equals? name "wyndupboy") "") - ((s-equals? name "hellpie") "πŸ₯§") ;; owed 1 - ((s-equals? name "steeledshield") "⛨") - ((s-equals? name "asrael_io") (propertize "Q" 'display (create-image (w/twitch-emote-path "emotesv2_a9dc5935824a4d6792f4b48f91031fcf")))) - ((s-equals? name "nichepenguin") "πŸ’š") - ;; ((s-equals? name "h_ingles") "") - ;; ((s-equals? name "compilingjay") "") - ;; ((s-equals? name "watchmakering") "") - ((s-equals? name "the0x539") "︘") - ((s-equals? name "colinahscopy_") "⚜") - ;; ((s-equals? name "eighteyedsixwingedseraph") "") - ;; ((s-equals? name "a_tension_span") "") - ;; ((s-equals? name "tomaterr") "") - ((s-equals? name "realnaesten") (propertize "Q" 'display (create-image (w/twitch-emote-path "emotesv2_4d2812c659c14c64a9a4044c3eff6d30")))) - ;; ((s-equals? name "fmega") "") - ;; ((s-equals? name "cr4zyk1tty") "") - ;; ((s-equals? name "devts_de") "") - ;; ((s-equals? name "physbuzz") "") - ((s-equals? name "sundemoniac") "🌞") - (t "EL."))) - (when (-contains? badges "vip/1") "πŸ’Ž") - (when (-contains? badges "subscriber/0") "πŸ’»") - (when (-contains? badges "founder/0") "πŸ–₯️")))))) + #'s-concat + (-non-nil + (list + (when (and aoc-stars (>= aoc-stars max-stars)) "πŸŽ„") + (when (-contains? badges "broadcaster/1") "(it me)") + (when (-contains? badges "moderator/1") "βš”") + (when (-contains? badges "artist-badge/1") "πŸ–ŒοΈ") + (when (and equity (> equity 0)) + (cond ;; The Equity Lords + ((s-equals? name "bezelea") "β™ΏπŸ””") ;; owed 1 + ((s-equals? name "altovt") "πŸ“ˆ") + ((s-equals? name "prodzpod") "πŸŒ πŸŒŒπŸŽ‘") ;; owed 1 emote + ((s-equals? name "faeliore") "😹") + ((s-equals? name "vasher_1025") "πŸ•΄") + ((s-equals? name "leadengin") "πŸ’ˆ") + ;; ((s-equals? name "kettlestew") "") + ((s-equals? name "blazynights") "πŸ€„") + ;; ((s-equals? name "must_broke_") "") + ((s-equals? name "bvnanana") "πŸ§‰") + ((s-equals? name "venorrak") "πŸ“ΊπŸ“œ") + ;; ((s-equals? name "tf_tokyo") "") + ((s-equals? name "devts_de") "βˆƒ") + ((s-equals? name "trap_exit") (s-concat (propertize "Q" 'display (create-image (w/twitch-emote-path "emotesv2_dfc4c36ccd3b4994b8ca4f082230f053"))) "β˜ πŸ’€")) + ((s-equals? name "essento") "πŸ₯š") + ((s-equals? name "tyumici") "🀌") + ;; clone is lord ((s-equals? name "liquidcake1") "") + ;; ((s-equals? name "loufbread_") "") + ((s-equals? name "yellowberryhn") "πŸͺ΄") + ;; ((s-equals? name "maradyne_") "") ;; owed 1 + ;; ((s-equals? name "sampie159") "") + ((s-equals? name "zamielpayne") "πŸ¦‰") + ((s-equals? name "xorxavier") "🌸") + ((s-equals? name "6horntaurus") "⚰️") ;; owed 1 + ((s-equals? name "bytomancer") (propertize "Q" 'display (create-image (w/twitch-emote-path "emotesv2_beb191005b81486c8b1c823931c88387")))) + ;; ((s-equals? name "henriqmarq") "") + ;; ((s-equals? name "wyndupboy") "") + ((s-equals? name "hellpie") "πŸ₯§") ;; owed 1 + ((s-equals? name "steeledshield") "⛨") + ((s-equals? name "asrael_io") (propertize "Q" 'display (create-image (w/twitch-emote-path "emotesv2_a9dc5935824a4d6792f4b48f91031fcf")))) + ((s-equals? name "nichepenguin") "πŸ’š") + ;; ((s-equals? name "h_ingles") "") + ;; ((s-equals? name "compilingjay") "") + ;; ((s-equals? name "watchmakering") "") + ((s-equals? name "the0x539") "︘") + ((s-equals? name "colinahscopy_") "⚜") + ;; ((s-equals? name "eighteyedsixwingedseraph") "") + ;; ((s-equals? name "a_tension_span") "") + ;; ((s-equals? name "tomaterr") "") + ((s-equals? name "realnaesten") (propertize "Q" 'display (create-image (w/twitch-emote-path "emotesv2_4d2812c659c14c64a9a4044c3eff6d30")))) + ;; ((s-equals? name "fmega") "") + ;; ((s-equals? name "cr4zyk1tty") "") + ;; ((s-equals? name "devts_de") "") + ;; ((s-equals? name "physbuzz") "") + ((s-equals? name "sundemoniac") "🌞") + ((s-equals? name "pralkarz") "🌞") + (t "EL."))) + (when (-contains? badges "vip/1") "πŸ’Ž") + (when (-contains? badges "subscriber/0") "πŸ’»") + (when (-contains? badges "founder/0") "πŸ–₯️")))))) (defun w/twitch-handle-incoming-chat (user tags text) "Write the message TEXT from USER with TAGS to the chat buffer. Process any commands included." + (w/binary-pub "overlay combo message" (s-join "," (--map (format "%s" it) (w/combo-classify text)))) (w/user-bind user - (lambda () - (let* ( (userid (car (w/saget "user-id" tags))) - (color (car (w/saget "color" tags))) + (lambda (uid unm) + (let* ( (color (car (w/saget "color" tags))) (emotes (car (w/saget "emotes" tags))) (badges (s-split "," (car (w/saget "badges" tags)))) (biblicality (w/bible-colorize-sentence text)) @@ -587,27 +599,25 @@ Process any commands included." (s-split "/" emotes) text-colored-bible)))) (push (cons user text) w/twitch-chat-history) - (w/user-stats-update) - (w/user-stats-update-color color) - (w/hexamedia-update-user user) - (w/shindaggers-update-user user) - (w/copfish-update-user user) + (w/user-stats-update uid unm) + (w/user-color-update uid unm color) (when (s-equals? (s-downcase user) "modclonk") (w/obs-activate-toggle 'modclonk)) - (w/resolve-record-user user) (w/hex-tick user) - (w/hex-transform - user - (w/make-chat-message - :user user - :id userid - :text text-with-emotes - :user-color (when (s-present? color) color) - :biblicality (cdr biblicality) - :sigil (w/twitch-badges-sigil badges))) + (w/user-badge-text uid + (lambda (sigils) + (w/hex-transform + user + (w/make-chat-message + :user user + :id uid + :text text-with-emotes + :user-color (when (s-present? color) color) + :biblicality (cdr biblicality) + :sigil (s-concat sigils (w/twitch-badges-sigil badges)))))) (--each w/twitch-chat-commands (when (s-contains? (car it) text) - (funcall (cdr it) user text))))))) + (funcall (cdr it) uid user text))))))) (defun w/twitch-handle-incoming-chat-sexp (msg) "Write MSG to the chat buffer, processing any commands." @@ -622,9 +632,9 @@ Optionally, only apply redeems with point costs less than LIMIT." (if (or (not limit) (< (car handler) limit)) (w/user-bind user - (lambda () + (lambda (uid unm) (condition-case err - (funcall (cadr handler) user input) + (funcall (cadr handler) uid unm input) (error (w/chat-write-event (format "Error during redeem: %s" err)))))) (w/chat-write-event (format "User %s attempted to activate overly expensive redeem \"%s\" via API" user redeem))) @@ -632,7 +642,7 @@ Optionally, only apply redeems with point costs less than LIMIT." (defun w/twitch-handle-redeem (r) "Handle the channel point redeem R." - ;; (w/write-log r) + (w/write-log r) (let* ((user (car r)) (redeem (cadr r)) (encoded-input (caddr r)) -- cgit v1.2.3