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-user-badges.el | |
| parent | cf266a56f30daae8b9af7c9bc3267c61b1973192 (diff) | |
Diffstat (limited to 'src/wasp-user-badges.el')
| -rw-r--r-- | src/wasp-user-badges.el | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/src/wasp-user-badges.el b/src/wasp-user-badges.el new file mode 100644 index 00000000..d34a9fa6 --- /dev/null +++ b/src/wasp-user-badges.el @@ -0,0 +1,164 @@ +;;; wsp-user-badges --- badges -*- lexical-binding: t; -*- +;;; Commentary: +;;; Code: + +(require 'wasp-utils) +(require 'wasp-db) + +(defvar w/badge-cache (ht-create)) +(defun w/badge-populate-cache () + "Populate the `w/badge-cache' with all badges." + (message "Populating badge cache...") + (w/db-hgetall "badge:name" + (lambda (bnames) + (message "Retrieved names...") + (w/db-hgetall "badge:desc" + (lambda (bdescs) + (message "Retrieved descriptions...") + (w/db-hgetall "badge:mode" + (lambda (bmodes) + (message "Retrieved modes...") + (w/db-hgetall "badge:text" + (lambda (btexts) + (message "Retrieved text...") + (w/db-hgetall "badge:icon" + (lambda (bicons) + (message "Retrieved icons!") + (ht-clear! w/badge-cache) + (--each (ht-keys bnames) + (message "Processing badge: %s" it) + (ht-set! w/badge-cache it + (ht<-alist + `( (name . ,(ht-get bnames it)) + (desc . ,(ht-get bdescs it)) + (mode . ,(ht-get bmodes it)) + (text . ,(ht-get btexts it)) + (icon . + ,(when-let* ((data (ht-get bicons it))) + (create-image + (encode-coding-string data 'no-conversion) + nil t + :height 20 + :ascent 'center)))))))))))))))))) + +(defun w/user-badge-text (uid k) + "Pass a string of badges to attach to UID's messages to K." + (w/db-smembers (s-concat "user:badges:" uid) + (lambda (badges) + (funcall k + (s-join "" + (--map + (when-let* ((b (ht-get w/badge-cache it))) + (cond + ((s-equals? (ht-get b 'mode) "text") + (ht-get b 'text)) + ((s-equals? (ht-get b 'mode) "icon") + (propertize "Q" 'display (ht-get b 'icon))))) + badges)))))) + +(defun w/badge-create-text (bid name desc text) + "Create a new talent BID called NAME with DESC and TEXT." + (w/db-hset "badge:name" bid name) + (w/db-hset "badge:desc" bid desc) + (w/db-hset "badge:mode" bid "text") + (w/db-hset "badge:text" bid text)) + +(defun w/badge-create-icon (bid name desc iconpath) + "Create a new talent BID called NAME with DESC and ICONPATH." + (let ((icon (or (f-read-bytes iconpath) (error "Failed to open icon path: %s" iconpath)))) + (progn + (w/db-hset "badge:name" bid name) + (w/db-hset "badge:desc" bid desc) + (w/db-hset "badge:mode" bid "icon") + (w/db-hset "badge:icon" bid icon)))) + +(defun w/badge-grant (uid bid) + "Give badge BID to user UID." + (w/db-sadd (s-concat "user:badges:" uid) bid)) + +(defun w/badge-custom-equity-text (user text) + "Give badge TEXT to USER." + (let ((bid (w/uuid))) + (w/badge-create-text bid "Equity Lord" "This user holds Equity Lordship status, entitling them to a vote at the shareholders' meeting." text) + (w/user-id-from-name user + (lambda (uid) + (w/badge-grant uid bid))))) + +(defun w/badge-custom-equity-icon (user icon) + "Give badge ICON to USER." + (let ((bid (w/uuid))) + (w/badge-create-icon bid "Equity Lord" "This user holds Equity Lordship status, entitling them to a vote at the shareholders' meeting." icon) + (w/user-id-from-name user + (lambda (uid) + (w/badge-grant uid bid))))) + +(defun w/badge-default-equity (user) + "Give USER the default equity badge." + (w/user-id-from-name user + (lambda (uid) + (w/badge-grant uid "equitylord")))) + +;; (w/badge-create-icon "equitylord" "Equity Lord" "This user holds Equity Lordship status, entitling them to a vote at the shareholders' meeting." (w/asset "badges/equitylord.png")) +;; (w/badge-create-text "themale" "MALE" "This user is known as \"The Male\" by some." "ð§ââïļ") +;; (w/badge-create-icon "slime" "Slime" "This user is \"slime\"." (w/asset "badges/slime.png")) +;; (w/user-id-from-name "LCOLONQ" +;; (lambda (uid) +;; (w/badge-grant uid "equitylord") +;; (w/badge-grant uid "themale") +;; )) +;; (w/user-id-from-name "acher0_" (lambda (uid) (w/badge-grant uid "slime"))) +;; (w/badge-custom-equity-text "bezelea" "âŋ") +;; (w/badge-custom-equity-text "bezelea" "ð") +;; (w/badge-custom-equity-text "altovt" "ð") +;; (w/badge-custom-equity-text "prodzpod" "ð ") +;; (w/badge-custom-equity-text "prodzpod" "ð") +;; (w/badge-custom-equity-text "prodzpod" "ð") +;; (w/badge-custom-equity-text "faeliore" "ðđ") +;; (w/badge-custom-equity-text "vasher_1025" "ðī") +;; (w/badge-custom-equity-text "leadengin" "ð") +;; (w/badge-default-equity "kettlestew") +;; (w/badge-custom-equity-text "blazynights" "ð") +;; (w/badge-default-equity "must_broke_") +;; (w/badge-custom-equity-text "bvnanana" "ð§") +;; (w/badge-custom-equity-text "venorrak" "ðš") +;; (w/badge-custom-equity-text "venorrak" "ð") +;; (w/badge-default-equity "tf_tokyo") +;; (w/badge-custom-equity-text "devts_de" "â") +;; (w/badge-custom-equity-icon "trap_exit" (w/twitch-emote-path "emotesv2_dfc4c36ccd3b4994b8ca4f082230f053")) +;; (w/badge-custom-equity-text "trap_exit" "â ") +;; (w/badge-custom-equity-text "trap_exit" "ð") +;; (w/badge-custom-equity-text "essento" "ðĨ") +;; (w/badge-custom-equity-text "tyumici" "ðĪ") +;; (w/badge-default-equity "liquidcake1") +;; (w/badge-default-equity "loufbread") +;; (w/badge-custom-equity-text "yellowberryhn" "ðŠī") +;; (w/badge-default-equity "maradyne_") +;; (w/badge-default-equity "sampie159") +;; (w/badge-custom-equity-text "zamielpayne" "ðĶ") +;; (w/badge-custom-equity-text "xorxavier" "ðļ") +;; (w/badge-custom-equity-text "6horntaurus" "â°") +;; (w/badge-custom-equity-icon "bytomancer" (w/twitch-emote-path "emotesv2_beb191005b81486c8b1c823931c88387")) +;; (w/badge-default-equity "henriqmarq") +;; (w/badge-default-equity "wyndupboy") +;; (w/badge-custom-equity-text "steeledshield" "âĻ") +;; (w/badge-custom-equity-icon "asrael_io" (w/twitch-emote-path "emotesv2_a9dc5935824a4d6792f4b48f91031fcf")) +;; (w/badge-custom-equity-text "nichepenguin" "ð") +;; (w/badge-default-equity "h_ingles") +;; (w/badge-default-equity "compilingjay") +;; (w/badge-default-equity "watchmakering") +;; (w/badge-custom-equity-text "the0x539" "ïļ") +;; (w/badge-custom-equity-text "colinahscopy_" "â") +;; (w/badge-default-equity "eighteyedsixwingedseraph") +;; (w/badge-default-equity "a_tension_span") +;; (w/badge-default-equity "tomaterr") +;; (w/badge-custom-equity-icon "realnaesten" (w/twitch-emote-path "emotesv2_4d2812c659c14c64a9a4044c3eff6d30")) +;; (w/badge-default-equity "fmega") +;; (w/badge-default-equity "cr4zyk1tty") +;; (w/badge-default-equity "physbuzz") +;; (w/badge-custom-equity-text "sundemoniac" "ð") +;; (w/badge-custom-equity-text "pralkewe67" "ð") +;; (w/badge-custom-equity-text "nichePenguin" "ðâðĐ") +;; (w/badge-custom-equity-icon "ellg" (w/twitch-emote-path "emotesv2_27a7f5d066144fb59490efae6c91820a")) + +(provide 'wasp-user-badges) +;;; wasp-user-badges.el ends here |
