Permalink
Browse files

v0.2 (debug code, better brain output)

  • Loading branch information...
1 parent 187e0af commit 598cc44ad15adf7752176179878e354941ec1e95 @jonnay committed Oct 10, 2012
Showing with 71 additions and 11 deletions.
  1. +1 −1 README.org
  2. +41 −4 ergore.el
  3. +29 −6 ergore.org
View
@@ -2,7 +2,7 @@
** An Emacs IRC bot using ERC
-Please check ergore.org for documenation.
+rePlease check ergore.org for documenation.
And Code examples.
View
@@ -15,6 +15,33 @@
(defconst ergore-invocation "ERGORE!")
+(defconst ergore-invocation "ERGORE!")
+
+(defcustom ergore-commands
+ (append '((test . ergore-command-test)
+ (info . ergore-command-info)
+ (help . ergore-command-help)
+ (seen . ergore-command-seen)
+ (time . ergore-command-seen)
+ (why . ergore-command-why)
+ (poke . ergore-command-force))
+
+ (when (featurep 'sauron)
+ '((ping . ergore-command-ping)))
+
+ (when (featurep 'mindwave-emacs)
+ '((brain . ergore-command-brain)))
+
+ (when (featurep 'emagician-starter-kit)
+ '((chao . ergore-command-chao))))
+
+ "An associative list of command names and functions to call in the format of:
+((command-name-symbol . (lambda () ...))
+ (command-name-symbol2 . 'funname))"
+ :type '(alist :key-type symbol :value-type function))
+
+(defvar ergore-debug t)
+
(defun ergore-command-test (data &rest args)
"Test command. Outputs to the Emacs log. NO one will see it."
(message "Data: %S Args: %S" data args))
@@ -101,9 +128,18 @@ LINES should be a string or a list of strings, which are the lines to send to th
"Jonnay's mindwave has a bad connection right now"))
(t
(ergore-send (ergore-get-nick data)
- (format "Attentive: %d%% Relaxed: %d%%"
- (mindwave/access-in 'eSense 'attention brain)
- (mindwave/access-in 'eSense 'meditation brain)))))))
+ (list (format "Attentive: %d/100 Relaxed: %d/100"
+ (mindwave/access-in 'eSense 'attention brain)
+ (mindwave/access-in 'eSense 'meditation brain))
+ (format "Relative EEG: δ:%s θ:%s α:%s %s β:%s %s γ:%s %s "
+ (mindwave/access-in 'eegPower 'delta brain)
+ (mindwave/access-in 'eegPower 'theta brain)
+ (mindwave/access-in 'eegPower 'lowAlpha brain)
+ (mindwave/access-in 'eegPower 'highAlpha brain)
+ (mindwave/access-in 'eegPower 'lowBeta brain)
+ (mindwave/access-in 'eegPower 'highBeta brain)
+ (mindwave/access-in 'eegPower 'lowGamma brain)
+ (mindwave/access-in 'eegPower 'highGamma brain))))))))
(defun ergore-command-chao (data &rest args)
"Make me read to you from a chaotic book of wisdom. Could be long, could be short..."
@@ -118,7 +154,8 @@ LINES should be a string or a list of strings, which are the lines to send to th
(defun ergore-run-command (cmd-string)
"Main dispatch for running an ergore command."
- (message "Ergore received command %s" cmd-string)
+ (when ergore-debug
+ (message "Ergore received command %s" cmd-string))
(let* ((cmd-parts (split-string (substring-no-properties cmd-string)))
(cmd (intern (substring-no-properties (car cmd-parts))))
(args (cdr cmd-parts))
View
@@ -19,6 +19,8 @@
;; Please see the org-file that this was generated from.
#+end_src
+Note, if you are reading this on Github, it won't work untill they update their org-mode parser to respond properly to the ~#+begin_src~ blocks.
+
* Mission
Provide a simple robot to be in intermediary between spell weaving (coding) and the outside world.
@@ -27,6 +29,10 @@
- v0.1 :: First Version!
+ - v0.2 ::
+ - Added some debug code
+ - Ergore brain more descriptive
+
* Caveats
- This is super-beta software. Right now it works great on my emacs, with only one IRC server, using bitlbee.
@@ -55,6 +61,10 @@ ERGORE! sleep!
** ~ergore-commands~
Commands are defined in a customizable variable that contains a list of commands to be executed.
+
+*** TODO fix brain/ping/chao to work once loaded.
+
+#+begin_src emacs-lisp
(defconst ergore-invocation "ERGORE!")
(defcustom ergore-commands
@@ -80,6 +90,8 @@ ERGORE! sleep!
(command-name-symbol2 . 'funname))"
:type '(alist :key-type symbol :value-type function))
+ (defvar ergore-debug t)
+
#+end_src
** Writing your own command
@@ -251,9 +263,18 @@ send me "ERGORE! info" to interact with my robot helper
"Jonnay's mindwave has a bad connection right now"))
(t
(ergore-send (ergore-get-nick data)
- (format "Attentive: %d%% Relaxed: %d%%"
- (mindwave/access-in 'eSense 'attention brain)
- (mindwave/access-in 'eSense 'meditation brain)))))))
+ (list (format "Attentive: %d/100 Relaxed: %d/100"
+ (mindwave/access-in 'eSense 'attention brain)
+ (mindwave/access-in 'eSense 'meditation brain))
+ (format "Relative EEG: δ:%s θ:%s α:%s %s β:%s %s γ:%s %s "
+ (mindwave/access-in 'eegPower 'delta brain)
+ (mindwave/access-in 'eegPower 'theta brain)
+ (mindwave/access-in 'eegPower 'lowAlpha brain)
+ (mindwave/access-in 'eegPower 'highAlpha brain)
+ (mindwave/access-in 'eegPower 'lowBeta brain)
+ (mindwave/access-in 'eegPower 'highBeta brain)
+ (mindwave/access-in 'eegPower 'lowGamma brain)
+ (mindwave/access-in 'eegPower 'highGamma brain))))))))
#+end_src
*** !ERGORE chao
@@ -283,7 +304,8 @@ send me "ERGORE! info" to interact with my robot helper
(defun ergore-run-command (cmd-string)
"Main dispatch for running an ergore command."
- (message "Ergore received command %s" cmd-string)
+ (when ergore-debug
+ (message "Ergore received command %s" cmd-string))
(let* ((cmd-parts (split-string (substring-no-properties cmd-string)))
(cmd (intern (substring-no-properties (car cmd-parts))))
(args (cdr cmd-parts))
@@ -299,10 +321,11 @@ send me "ERGORE! info" to interact with my robot helper
(t
(message "Ergore: Someone tried to call %s with %s. (%s)" cmd args data)))
(message "Ergore: Unknown command %s" cmd)))))
-
+
(add-hook 'erc-insert-pre-hook 'ergore-erc-hook)
#+end_src
-
+*** TODO determine whether or not it makes sence to refactor it to be more functional
+ - should a command return a list that is the string to send back?
** Tests. Sorry, they suck for now.
#+begin_src emacs-lisp :export yes :tangle no
(ert-deftest test-egregore-run-command ()

0 comments on commit 598cc44

Please sign in to comment.