diff options
| author | LLLL Colonq <llll@colonq> | 2026-04-26 23:47:18 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2026-04-26 23:47:18 -0400 |
| commit | 75e005e81b73d8471f16dc5fad7bbdc312bdbfe7 (patch) | |
| tree | 1ad7d61b04c44fc52b453aef44868a42012f3551 /src/wasp-twitch.el | |
| parent | cf266a56f30daae8b9af7c9bc3267c61b1973192 (diff) | |
Diffstat (limited to 'src/wasp-twitch.el')
| -rw-r--r-- | src/wasp-twitch.el | 240 |
1 files changed, 125 insertions, 115 deletions
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)) |
