summaryrefslogtreecommitdiff
path: root/src/gizmo/wasp-chatsummary.el
blob: 5a6a27ae224d65995e801a7249025f5ac1afff8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
;;; wasp-chatsummary --- Stealing a YouTube feature -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:

(require 'wasp-ai)
(require 'wasp-friend)

(defcustom w/chatsummary-buffer "*wasp-chatsummary*"
  "Name of buffer used to display chat summary."
  :type '(string)
  :group 'wasp)

(define-derived-mode w/chatsummary-mode special-mode "Chat Summary"
  "Major mode for displaying chat summary."
  :group 'w
  (setq-local cursor-type nil)
  (visual-line-mode))

(defun w/chatsummary-get-buffer ()
  "Return the chatsummary buffer."
  (unless (get-buffer w/chatsummary-buffer)
    (with-current-buffer (get-buffer-create w/chatsummary-buffer)
      (w/chatsummary-mode)))
  (get-buffer w/chatsummary-buffer))

(defun w/update-chatsummary ()
  "Update the chat summary."
  (w/ai
   (w/friend-journalism-input)
   (lambda (d)
     (when-let* ((d)
                 (resp (s-trim d)))
       (with-current-buffer (w/chatsummary-get-buffer)
         (let ((inhibit-read-only t))
           (erase-buffer)
           (w/write-line "Chat summary" 'bold)
           (w/write-line resp)))))
   "Given a list of recent YouTube chatter activity, produce a summary of the topics discussed. The summary should be very short, maximum two sentences total. Do not introduce yourself. Simply provide a short summary of the chat. Do not mention specific names of chatters. Keep it succinct. Do not mention that you are summarizing YouTube activity. Be laconic."))

(defvar w/chatsummary-timer nil)
(defun w/run-chatsummary-timer ()
  "Run the chat summary timer."
  (when w/chatsummary-timer
    (cancel-timer w/chatsummary-timer))
  (w/update-chatsummary)
  (setq
   w/chatsummary-timer
   (run-with-timer 120 nil #'w/run-chatsummary-timer)))

(defun w/start-chatsummary ()
  "Enable fake chatters."
  (interactive)
  (w/run-chatsummary-timer))

(defun w/stop-chatsummary ()
  "Disable fake chatters."
  (interactive)
  (cancel-timer w/chatsummary-timer)
  (setq w/chatsummary-timer nil))

(provide 'wasp-chatsummary)
;;; wasp-chatsummary.el ends here