summaryrefslogtreecommitdiff
path: root/Biz/Bot.scm
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2024-11-15 14:55:37 -0500
committerBen Sima <ben@bsima.me>2024-12-21 10:06:49 -0500
commit6513755670892983db88a6633b8c1ea6019c03d1 (patch)
tree44e9eccdb7a3a74ab7e96a8fee7572dd6a78dc73 /Biz/Bot.scm
parentae7b7e0186b5f2e0dcd4d5fac0a71fa264caedc2 (diff)
Re-namespace some stuff to Omni
I was getting confused about what is a product and what is internal infrastructure; I think it is good to keep those things separate. So I moved a bunch of stuff to an Omni namespace, actually most stuff went there. Only things that are explicitly external products are still in the Biz namespace.
Diffstat (limited to 'Biz/Bot.scm')
-rwxr-xr-xBiz/Bot.scm59
1 files changed, 0 insertions, 59 deletions
diff --git a/Biz/Bot.scm b/Biz/Bot.scm
deleted file mode 100755
index 81e04f0..0000000
--- a/Biz/Bot.scm
+++ /dev/null
@@ -1,59 +0,0 @@
-;; : out bizbot
-;;
-;; Usage with ii:
-;;
-;; tail -f \#biz/out | guile -L $CODEROOT -s Biz/Bot.scm
-;;
-(define-module (Biz Bot) #:export (main))
-
-(import (ice-9 rdelim))
-(import (ice-9 match))
-(import (ice-9 regex))
-(import (ice-9 receive))
-(import (bs core))
-(import (prefix (bs string) string.))
-
-(define (log msg)
- (display msg (current-error-port)))
-
-(define (is-command? msg)
- (string.prefix? msg "bizbot:"))
-
-(define (parse-line line)
- (if (eof-object? line)
- (exit)
- (let ([matches (regexp-exec
- (make-regexp "<(\\S*)>(.*)" regexp/extended)
- (string-drop line 11))])
- (if matches
- `(user
- ,(match:substring matches 1)
- ,(string.lstrip (match:substring matches 2) #\space))
- `(system ,(string-drop line 11))))))
-
-(define (dispatch user msg)
- (let ([msg (-> msg
- (string-drop (string-length "bizbot:"))
- (string.lstrip #\space))])
- (cond
- ((equal? msg "hi")
- (display (fmt "~a: well, hello!" user)))
-
- (else
- (display (fmt "command not understood: ~a" msg))))))
-
-(define (main args)
- (while #t
- (match (parse-line (read-line))
- [('user user msg)
- (if (is-command? msg)
- (dispatch user msg)
- (begin
- (log (fmt "user: ~a " user))
- (log (fmt "message: ~a" msg))))]
-
- [('system msg)
- (log (fmt "system: ~a" msg))])
-
- (newline)
- (force-output)))