summaryrefslogtreecommitdiff
path: root/src/gizmo/wasp-gcp.el
blob: cd1bfa8183ebd6533e336bad673c17761a092d39 (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
;;; wasp-gcp --- Global consciousness project integration -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:

(require 'dash)
(require 's)
(require 'f)
(require 'ht)
(require 'cl-lib)
(require 'request)
(require 'dom)

(defcustom w/gcp-server "https://global-mind.org"
  "Server URL for GCP project."
  :type '(string)
  :group 'wasp)

(defvar w/gcp-last-response nil)
(defvar w/gcp 0.0)

(defun w/gcp-get (loc k)
  "Get LOC from GCP, passing the returned HTML to K."
  (setf request-message-level -1)
  (request
    (s-concat w/gcp-server loc)
    :type "GET"
    :parser (lambda () (libxml-parse-xml-region (point-min) (point-max)))
    :success
    (cl-function
     (lambda (&key data &allow-other-keys)
       (setq w/gcp-last-response data)
       (funcall k data))))
  t)

(defun w/gcp-dot (k)
  "Pass the current GCP index (as a number between 0 and 1) to K."
  (w/gcp-get
   "/gcpdot/gcpindex.php"
   (lambda (d)
     (when-let* ((ds (caddar (last (cddr (cadddr d))))))
       (setf w/gcp (string-to-number ds))
       (funcall k w/gcp)))))

(defun w/gcp-describe (n)
  "Describe GCP index N."
  (cond
   ((< n 0.05) "Red dot. Significantly large network variance. Suggests broadly shared coherence of thought and emotion.")
   ((< n 0.10) "Orange dot. Strongly increased network variance. May be chance fluctuation.")
   ((< n 0.40) "Yellow dot. Slightly increased network variance. Probably chance fluctuation.")
   ((< n 0.90) "Green dot. Normally random network variance. This is average or expected behavior.")
   ((< n 0.95) "Light blue dot. Small network variance. Probably chance fluctuation.")
   (t "Blue dot. Significantly small network variance. Suggestive of deeply shared, internally motivated group focus.")))

(defun w/gcp-update ()
  "Update the GCP index."
  (w/gcp-dot (lambda (_) nil)))
(add-hook 'w/gizmo-update-hook #'w/gcp-update)

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