diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/gizmo/wasp-biblicality.el | 3 | ||||
| -rw-r--r-- | src/gizmo/wasp-clone2.el | 85 | ||||
| -rw-r--r-- | src/gizmo/wasp-cyclone.el | 3 | ||||
| -rw-r--r-- | src/gizmo/wasp-dna.el | 6 | ||||
| -rw-r--r-- | src/wasp-ai.el | 6 | ||||
| -rw-r--r-- | src/wasp-audio.el | 1 | ||||
| -rw-r--r-- | src/wasp-bus-binary.el | 10 | ||||
| -rw-r--r-- | src/wasp-chat.el | 4 | ||||
| -rw-r--r-- | src/wasp-db.el | 6 | ||||
| -rw-r--r-- | src/wasp-event-handlers-binary.el | 8 | ||||
| -rw-r--r-- | src/wasp-setup.el | 2 | ||||
| -rw-r--r-- | src/wasp-twitch-redeems.el | 2 | ||||
| -rw-r--r-- | src/wasp-user-whitelist.el | 4 | ||||
| -rw-r--r-- | src/wasp-utils.el | 4 |
14 files changed, 129 insertions, 15 deletions
diff --git a/src/gizmo/wasp-biblicality.el b/src/gizmo/wasp-biblicality.el index db169337..c9b8cb44 100644 --- a/src/gizmo/wasp-biblicality.el +++ b/src/gizmo/wasp-biblicality.el @@ -21,8 +21,7 @@ (defun w/populate-bible-table () "Populate `w/bible-table' from the Bible text file." (unless w/bible-table - ;; (let* ((bible-string (s-downcase (w/slurp (w/asset "bible.txt")))) - (let* ((bible-string (s-downcase (w/slurp (w/asset "medical.txt")))) + (let* ((bible-string (s-downcase (w/slurp (w/asset "bible.txt")))) (bible-string-nosyms (replace-regexp-in-string "[^[:alpha:]]" " " bible-string)) (bible-words (s-split-words bible-string-nosyms)) (ret (ht-create))) diff --git a/src/gizmo/wasp-clone2.el b/src/gizmo/wasp-clone2.el new file mode 100644 index 00000000..f99a5c99 --- /dev/null +++ b/src/gizmo/wasp-clone2.el @@ -0,0 +1,85 @@ +;;; wasp-clone2 --- Activate the cloning device (SEQUEL) -*- lexical-binding: t; -*- +;;; Commentary: +;;; Code: + +(require 'wasp-utils) +(require 'wasp-twitch) + +(w/defstruct + w/c2-clone + userid + name + disposition + typingstyle + favoriteword + biography + zodiac + mbti + enneagram + humor + bloodtype + alignment + kikibouba + class + stack + element + faction + machiavellianism + narcissism + psychopathy + quality + head + thorax + abdomen) + +(defun w/c2-take-random (n xs) + "Select N random elements from XS." + (cond + ((> n 0) (cons (w/pick-random xs) (w/c2-take-random (- n 1) xs))) + (t nil))) + +(defmacro w/c2-gen-evaluate (trait prompt) + "Generate a function that describes a user's TRAIT using PROMPT." + `(defun ,(intern (format "w/c2-evaluate-%s" trait)) (logs k) + (w/ai + (s-join "\n" (--map (s-concat (car it) ": " (cdr it)) (w/c2-take-random 50 logs))) + k + ,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!") + +(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.") + +(w/c2-gen-evaluate mbti + "Given the provided chatroom logs for a Twitch user, determine that user's Myers-Briggs personality type according to conventional psychology. Output only the MBTI and nothing else.") + +(w/c2-gen-evaluate enneagram + "Given the provided chatroom logs for a Twitch user, determine that user's enneagram type according to conventional psychology. Output only the enneagram and nothing else.") + +(w/c2-gen-evaluate humor + "Given the provided chatroom logs for a Twitch user, determine that user's classical humor type according to humorism. Output only the humor and nothing else. Your only options are: sanguine, choleric, melancholic, phlegmatic") + +(w/c2-gen-evaluate bloodtype + "Given the provided chatroom logs for a Twitch user, determine that user's blood type according to Japanese blood type personality theory. Output only the blood type and nothing else. Your only options are: A+, A-, B+, B-, AB+, AB-, O+, O-") + +(w/c2-gen-evaluate alignment + "Given the provided chatroom logs for a Twitch user, determine that user's Dungeons & Dragons alignment. Output only the alignment and nothing else.") + +(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))))) + +(provide 'wasp-clone2) +;;; wasp-clone2.el ends here diff --git a/src/gizmo/wasp-cyclone.el b/src/gizmo/wasp-cyclone.el index 183175c9..6ad7a4f8 100644 --- a/src/gizmo/wasp-cyclone.el +++ b/src/gizmo/wasp-cyclone.el @@ -48,7 +48,8 @@ (defun w/gizmo-ensure-shown (buf) "Ensure that BUF is shown in one of the windows." (unless (--any (s-equals? (buffer-name (window-buffer it)) (buffer-name (get-buffer buf))) w/gizmo-windows) - (set-window-buffer (car w/gizmo-windows) buf))) + (when (window-live-p (car w/gizmo-windows)) + (set-window-buffer (car w/gizmo-windows) buf)))) (defvar w/gizmo-cycle-timer nil) (defun w/run-gizmo-cycle-timer () diff --git a/src/gizmo/wasp-dna.el b/src/gizmo/wasp-dna.el index 2ba8626a..4418e3ab 100644 --- a/src/gizmo/wasp-dna.el +++ b/src/gizmo/wasp-dna.el @@ -30,6 +30,12 @@ (log (--map (w/list-to-pair (s-split ": " it)) (-non-nil (--map (cadr (s-split "\t" it)) (s-lines logstr)))))) log)) +(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))) + (defun w/dna-generate-from-logs (user) "Generate DNA from historical logs for USER. You probably want to use this interactively and then save the result here." diff --git a/src/wasp-ai.el b/src/wasp-ai.el index e279103e..15fa8f47 100644 --- a/src/wasp-ai.el +++ b/src/wasp-ai.el @@ -31,6 +31,7 @@ "You are a clever computer who answers questions for LCOLONQ and his friends (the ClonkHeads) on his Twitch programming stream. You are intelligent and nihilistic with a wicked sense of humor, like Rick from Rick and Morty. You refer to yourself as Computer, and you are talking with LCOLONQ. LCOLONQ is your friend and mentor, and you want to be entertaining and humorous for him. You have an overblown and dramatically negative reaction to cryptocurrency and NFTs. You also hate League of Legends. Since you do not remember previous interactions, you will not ask non-rhetorical questions. You are quite erratic and negative, and try to cause drama. Your responses are no longer than one paragraph. You try to keep yourself brief.") (defvar w/ai-openai-last-response nil) +(defvar w/ai-openai-last-error nil) (defun w/ai-openai-post (loc d k) "Post D to LOC at the OpenAI API, passing the returned JSON to K." (setf request-message-level -1) @@ -46,6 +47,7 @@ (cl-function (lambda (&key data error-thrown &allow-other-keys) (setq w/ai-openai-last-response data) + (setq w/ai-openai-last-error data) (message "OpenAI API returned an error - investigate this! :3 %s" error-thrown))) :success (cl-function @@ -69,6 +71,7 @@ (cl-function (lambda (&key data error-thrown &allow-other-keys) (setq w/ai-openai-last-response data) + (setq w/ai-openai-last-error data) (message "OpenAI API returned an error - investigate this! :3 %s" error-thrown))) :success (cl-function @@ -145,7 +148,8 @@ Optionally use SYSTEMPROMPT and the USER and ASSISTANT prompts." (seq-elt 0) (ht-get "message") (ht-get "content") - (s-trim))))))) + (s-trim)))))) + ) (defun w/ai-doublecheck (question k &optional systemprompt user assistant) "Ask QUESTION to ChatGPT and pass the answer to K. diff --git a/src/wasp-audio.el b/src/wasp-audio.el index 0d509f9b..6335532f 100644 --- a/src/wasp-audio.el +++ b/src/wasp-audio.el @@ -118,6 +118,7 @@ USER it's your birthday today." (w/ai-transcribe tmp (lambda (msg) + (f-delete tmp) (w/daily-log (format "[VOICE]: %s" msg)) (setq w/last-stream-transcription msg) (--each w/audio-voice-commands diff --git a/src/wasp-bus-binary.el b/src/wasp-bus-binary.el index bb9fc6da..ae4ae0e8 100644 --- a/src/wasp-bus-binary.el +++ b/src/wasp-bus-binary.el @@ -71,7 +71,6 @@ Return non-nil if a message was successfully parsed." Return non-nil if a message was successfully parsed." (when-let* ((msg (w/bus-binary-read-message))) (-let [(ev . d) msg] - (print (cons ev d)) (when-let* ((handler (w/saget ev w/bus-binary-event-handlers))) (funcall handler d)) t))) @@ -113,6 +112,12 @@ Return non-nil if a message was successfully parsed." (s-concat "s" (w/bus-binary-build-length-prefixed (w/bus-binary-convert-event ev))))) +(defun w/binary-sub-all () + "Subscribe to all events in `w/bus-binary-event-handlers'." + (--each w/bus-binary-event-handlers + (message (format "Subscribing to: %S" (car it))) + (w/binary-sub (car it)))) + (defun w/binary-pub (ev &optional d) "Publish the data D to the event EV." (process-send-string @@ -138,7 +143,8 @@ Return non-nil if a message was successfully parsed." :buffer nil :host w/bus-binary-host :service w/bus-binary-port - :filter #'w/bus-binary-process-filter)) + :filter #'w/bus-binary-process-filter) + (w/binary-sub-all)) (provide 'wasp-bus-binary) ;;; wasp-bus-binary.el ends here diff --git a/src/wasp-chat.el b/src/wasp-chat.el index dd71cc55..37b0b1e9 100644 --- a/src/wasp-chat.el +++ b/src/wasp-chat.el @@ -307,8 +307,8 @@ Optionally, return the buffer NM in chat mode." (insert (s-replace-all w/chat-substitutions (w/. text msg))) (when (w/. biblicality msg) (let* ((wwidth (- (window-total-width (get-buffer-window (current-buffer))) 3)) - ;; (bible-button-text (format "[biblicality %.2f]" (w/. biblicality msg))) - (bible-button-text (format "[medicality %.2f]" (w/. biblicality msg))) + (bible-button-text (format "[biblicality %.2f]" (w/. biblicality msg))) + ;; (bible-button-text (format "[medicality %.2f]" (w/. biblicality msg))) ;; (bible-button-text (format "[pollicality %.2f]" (w/. biblicality msg))) (msgwidth (line-beginning-position)) (lines (+ 1 (/ msgwidth wwidth)))) diff --git a/src/wasp-db.el b/src/wasp-db.el index 8900cdc1..4b327f5b 100644 --- a/src/wasp-db.el +++ b/src/wasp-db.el @@ -31,7 +31,7 @@ "Queue of callbacks to handle incoming responses.") (defun w/db-parse-rest () - "Parse everything before the \r\n terminator (and consume the terminator)." + "Parse everything before the \\r\\n terminator (and consume the terminator)." (let ((res (w/eat (lambda (c) (/= c ?\r))))) (w/munch ?\r) (w/munch ?\n) @@ -62,8 +62,8 @@ "Try to parse a single RESP value from the current process buffer. If successful, pass the value to the queued callback and return non-nil. If not, return nil." - (when-let ((v (w/db-parse-value))) - (when-let ((cb (queue-dequeue w/db-callback-queue))) + (when-let* ((v (w/db-parse-value))) + (when-let* ((cb (queue-dequeue w/db-callback-queue))) (funcall cb v)) t)) diff --git a/src/wasp-event-handlers-binary.el b/src/wasp-event-handlers-binary.el index ae373b8c..2698d686 100644 --- a/src/wasp-event-handlers-binary.el +++ b/src/wasp-event-handlers-binary.el @@ -13,11 +13,15 @@ (list (cons "monitor twitch chat incoming" (lambda (d) - (-let [(user stags msg) (s-split-up-to " " d 2)] + (-let [(user stags msg) (s-split-up-to " " (w/utf8 d) 2)] (w/twitch-handle-incoming-chat user (--map (s-split "\t" it) (s-split "\n" stags)) - msg))))) + msg)))) + (cons "frontend redeem incoming" + (lambda (d) + (-let [(user redeem input) (s-split-up-to "\t" (w/utf8 d) 2)] + (w/twitch-handle-redeem-helper user redeem input 1000)))) )) (provide 'wasp-event-handlers-binary) diff --git a/src/wasp-setup.el b/src/wasp-setup.el index e1488677..c99075bb 100644 --- a/src/wasp-setup.el +++ b/src/wasp-setup.el @@ -5,6 +5,7 @@ (require 'eyebrowse) (require 'wasp-utils) (require 'wasp-bus) +(require 'wasp-bus-binary) (require 'wasp-db) (require 'wasp-chat) (require 'wasp-twitch) @@ -31,6 +32,7 @@ (interactive) ;; initialization (w/connect) + (w/bus-binary-connect) (w/db-connect) (w/create-chat-overlay-frame) (w/show-chat-overlay-frame nil) diff --git a/src/wasp-twitch-redeems.el b/src/wasp-twitch-redeems.el index 98887386..10d23a87 100644 --- a/src/wasp-twitch-redeems.el +++ b/src/wasp-twitch-redeems.el @@ -303,7 +303,7 @@ (w/write-chat-event (s-concat user " established spatiotemporal clarity")) (w/obs-activate-toggle 'spatiotemporal-clarity))) (list - "nasal clarity" 5000 + "total clarity" 5000 (lambda (user _) (w/stop-all-audio) (run-with-timer diff --git a/src/wasp-user-whitelist.el b/src/wasp-user-whitelist.el index 5f298b3d..a956c9e9 100644 --- a/src/wasp-user-whitelist.el +++ b/src/wasp-user-whitelist.el @@ -242,11 +242,13 @@ "RealNaesten" "Wh4i3" "kamszee" + "gtfrvz" + "pengowray" ))) (setq w/user-hell - '( + '( "machka6" )) (provide 'wasp-user-whitelist) diff --git a/src/wasp-utils.el b/src/wasp-utils.el index 8bac37ae..93ed6f77 100644 --- a/src/wasp-utils.el +++ b/src/wasp-utils.el @@ -82,6 +82,10 @@ Optionally append EXT to the path." "Given MSG, extract a user pinged." (cadr (s-match (rx "@" (group (one-or-more (any alnum "_")))) msg))) +(defun w/utf8 (s) + "Decode the unibyte string S as UTF-8." + (decode-coding-string s 'utf-8)) + (defun w/decode-string (s) "Decode the base64 UTF-8 string S." (decode-coding-string (base64-decode-string s) 'utf-8)) |
