diff options
| author | LLLL Colonq <llll@colonq> | 2025-09-16 01:34:52 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2025-09-16 01:34:59 -0400 |
| commit | 510608fdbc43947391d82c703370814aa57a454e (patch) | |
| tree | 57c35f47ed5b2ce0c7eaa2a2553b0e39131475d5 | |
| parent | fe903c535211bdbeeb703e06db0da3f7c8c19b4b (diff) | |
Update
| -rw-r--r-- | assets/avatars/default.png | bin | 0 -> 389 bytes | |||
| -rw-r--r-- | src/gizmo/wasp-clone2.el | 93 | ||||
| -rw-r--r-- | src/gizmo/wasp-dna.el | 10 | ||||
| -rw-r--r-- | src/wasp-db.el | 4 | ||||
| -rw-r--r-- | src/wasp-twitch.el | 13 | ||||
| -rw-r--r-- | src/wasp-utils.el | 13 |
6 files changed, 114 insertions, 19 deletions
diff --git a/assets/avatars/default.png b/assets/avatars/default.png Binary files differnew file mode 100644 index 00000000..6d2e22cd --- /dev/null +++ b/assets/avatars/default.png diff --git a/src/gizmo/wasp-clone2.el b/src/gizmo/wasp-clone2.el index f99a5c99..3b76900f 100644 --- a/src/gizmo/wasp-clone2.el +++ b/src/gizmo/wasp-clone2.el @@ -4,6 +4,7 @@ (require 'wasp-utils) (require 'wasp-twitch) +(require 'wasp-dna) (w/defstruct w/c2-clone @@ -47,7 +48,7 @@ ,prompt))) (w/c2-gen-evaluate typingstyle - "Given the provided chatroom logs for a Twitch user, perform a forensic stylometry analysis of the form of the text. Try to identify key features of the text such as usage of abnormal punctuation/capitalization that would uniquely identify the user. Only describe the things that differ from a typical Twitch user. Your analysis should be summarized in at most two brief sentences. Do not provide any examples please. Please be brief and do not use unnecessary adjectives or adverbs! Be as short as possible! I am trying to mimic this user; present the information in a way that makes such mimicry easy!") + "Given the provided chatroom logs for a Twitch user, perform a forensic stylometry analysis of the form of the text. Try to identify key features of the text such as usage of abnormal punctuation/capitalization that would uniquely identify the user. Your analysis should be summarized in at most two brief sentences. Do not provide any examples please. Please be brief and do not use unnecessary adjectives or adverbs! Be as short as possible! I am trying to mimic this user; present the information in a way that makes such mimicry easy!") (w/c2-gen-evaluate zodiac "Given the provided chatroom logs for a Twitch user, determine that user's zodiac sign according to conventional astrology. Output only the zodiac sign and nothing else.") @@ -70,16 +71,86 @@ (w/c2-gen-evaluate kikibouba "Given the provided chatroom logs for a Twitch user, determine whether that user is more \"kiki\" or more \"bouba\". Output only kiki or bouba and nothing else.") -(defun w/c2-new (name k) - "Build a new (randomized) clone for NAME based on their DNA and profile. -Pass the resulting clone to K." - (w/twitch-get-user-id name - (lambda (userid) - (let ( (clone - (w/make-c2-clone - :userid userid - :name name))) - (funcall k clone))))) +(defun w/c2-new (name disposition biography) + "Build a new (randomized) clone for NAME with DISPOSITION based on their DNA. +The clone has a BIOGRAPHY describing it." + (let ( (clone + (w/make-c2-clone + :name name + :disposition disposition + :favoriteword "aardvark" + :biography biography + :class (w/pick-random (list "Fighter" "Magic-user" "Cleric" "Thief")) + :stack (w/pick-random (list "LAMP" "MEAN" "MERN" "MEVN" "JAM" "CLONK")) + :element (w/pick-random (list "fire" "water" "wind" "earth" "lightning" "heart")) + :faction (w/pick-random (list "nate" "lever" "tony")) + :quality (w/pick-random (list "F" "D" "C" "B" "A" "A+" "S-" "S+" "S++" "S+++")) + :narcissism (w/random-probability) + :machiavellianism (w/random-probability) + :psychopathy (w/random-probability) + :head + (w/encode-string + (f-read-bytes + (if (f-exists? (w/twitch-user-avatar-path name)) + (w/twitch-user-avatar-path name) + (w/twitch-user-avatar-path "default")))) + :thorax (w/random-color) + :abdomen (w/random-color))) + (total 0) + (timeout 0) + (logs (w/c2-take-random 30 (w/dna-user-log name))) + (fields '(typingstyle zodiac mbti enneagram humor bloodtype alignment kikibouba))) + (w/twitch-get-user-id name + (lambda (userid) + (setf (w/c2-clone-userid clone) userid) + (cl-incf total))) + (cl-decf total) + (--each fields + (funcall (intern (format "w/c2-evaluate-%s" it)) + logs + (lambda (x) + (setf (eieio-oref clone it) x) + (cl-incf total))) + (cl-decf total)) + (while (and (not (= total 0)) (< timeout 20)) + (message "Generating%s" (s-repeat timeout ".")) + (sleep-for 0.5) + (cl-incf timeout)) + clone)) + +(defun w/c2-upload (c) + "Upload the clone C to the database." + (let ((countkey (format "c2_count:%s" (w/c2-clone-userid c)))) + (w/db-get countkey + (lambda (old) + (let* ( (idx (if (s-present? old) (string-to-number old) 0)) + (key (format "c2_clone:%s:%s" (w/c2-clone-userid c) idx))) + (w/db-hmset key + "userid" (w/c2-clone-userid c) + "name" (w/c2-clone-name c) + "disposition" (w/c2-clone-disposition c) + "typingstyle" (w/c2-clone-typingstyle c) + "favoriteword" (w/c2-clone-favoriteword c) + "biography" (w/c2-clone-biography c) + "zodiac" (w/c2-clone-zodiac c) + "mbti" (w/c2-clone-mbti c) + "enneagram" (w/c2-clone-enneagram c) + "humor" (w/c2-clone-humor c) + "bloodtype" (w/c2-clone-bloodtype c) + "alignment" (w/c2-clone-alignment c) + "kikibouba" (w/c2-clone-kikibouba c) + "class" (w/c2-clone-class c) + "stack" (w/c2-clone-stack c) + "element" (w/c2-clone-element c) + "faction" (w/c2-clone-faction c) + "machiavellianism" (format "%s" (w/c2-clone-machiavellianism c)) + "narcissism" (format "%s" (w/c2-clone-narcissism c)) + "psychopathy" (format "%s" (w/c2-clone-psychopathy c)) + "quality" (w/c2-clone-quality c) + "head" (w/c2-clone-head c) + "thorax" (w/c2-clone-thorax c) + "abdomen" (w/c2-clone-abdomen c)) + (w/db-set countkey (format "%s" (+ idx 1)))))))) (provide 'wasp-clone2) ;;; wasp-clone2.el ends here diff --git a/src/gizmo/wasp-dna.el b/src/gizmo/wasp-dna.el index 4418e3ab..5c8f19a5 100644 --- a/src/gizmo/wasp-dna.el +++ b/src/gizmo/wasp-dna.el @@ -32,9 +32,13 @@ (defun w/dna-user-log (user) "Return a complete log of every message sent by USER." - (--filter - (s-equals? (s-downcase (car it)) user) - (w/dna-complete-log))) + (cond + ((s-equals? user "fake_test_user") + (-repeat 100 (cons "fake_test_user" "hello i'm the test user haha i love apples and oranges"))) + (t + (--filter + (s-equals? (s-downcase (car it)) (s-downcase user)) + (w/dna-complete-log))))) (defun w/dna-generate-from-logs (user) "Generate DNA from historical logs for USER. diff --git a/src/wasp-db.el b/src/wasp-db.el index 4b327f5b..fda53b85 100644 --- a/src/wasp-db.el +++ b/src/wasp-db.el @@ -154,6 +154,10 @@ Afterward call K." (w/db-cmd `("HSET" ,key ,hkey ,val ,@vals) (lambda (_) nil))) ;; (w/db-hset-then key hkey val (lambda (_) nil) vals)) +(defun w/db-hmset (key &rest vals) + "Set many keys in hash KEY to VALS in Redis." + (w/db-cmd `("HMSET" ,key ,@vals) (lambda (_) nil))) + (defun w/db-hget (key hkey k) "Get HKEY in hash KEY from Redis and pass the corresponding value to K." (w/db-cmd `("HGET" ,key ,hkey) k)) diff --git a/src/wasp-twitch.el b/src/wasp-twitch.el index bd92b435..87977cbd 100644 --- a/src/wasp-twitch.el +++ b/src/wasp-twitch.el @@ -185,11 +185,14 @@ (defun w/twitch-get-user-id (user k) "Get the ID for USER and pass it to K." - (w/twitch-api-get - (s-concat "/users?login=" user) - (lambda (data) - (let ((id (ht-get (aref (ht-get data "data") 0) "id"))) - (funcall k id))))) + (cond + ((s-equals? user "fake_test_user") (funcall k "69")) + (t + (w/twitch-api-get + (s-concat "/users?login=" user) + (lambda (data) + (let ((id (-some-> data (ht-get "data") (w/safe-elt 0) (ht-get "id")))) + (funcall k id))))))) (defun w/twitch-get-recent-clips (userid k) "Get clips from the last week for USERID and pass them to K." diff --git a/src/wasp-utils.el b/src/wasp-utils.el index 894c62f3..7b3c02b4 100644 --- a/src/wasp-utils.el +++ b/src/wasp-utils.el @@ -15,6 +15,11 @@ :type '(string) :group 'wasp) +(defun w/safe-elt (seq idx) + "Return the IDXth element of SEQ." + (when (< idx (seq-length seq)) + (seq-elt seq idx))) + (defun w/read-sexp (s) "Read string S into a Lisp form. Return nil on error." @@ -67,6 +72,14 @@ BODY is passed directly to `cl-defstruct'." (let ((elt (seq-elt s (random (seq-length s))))) (cons elt (w/shuffle (remove elt s)))))) +(defun w/random-probability () + "Return a random float between 0.0 and 1.0." + (/ (float (random most-positive-fixnum)) most-positive-fixnum)) + +(defun w/random-color () + "Return a random color string." + (format "#%02x%02x%02x" (random 256) (random 256) (random 256))) + (defun w/list-to-pair (xs) "Turn the first two elements of XS into a pair." (cons (car xs) (cadr xs))) |
