diff options
author | Ben Sima <ben@bsima.me> | 2021-06-07 13:41:53 -0400 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2021-11-26 13:47:35 -0500 |
commit | 310275abdc61130c8cc77f7827163f136d57b63f (patch) | |
tree | 34ff8993ff43c07bdd14bd1f673e3cf0bf71c1df /Biz/Bot.scm | |
parent | 287687ced99be8e0302e25099ef8e50d9c9b5eec (diff) |
Make executable
Diffstat (limited to 'Biz/Bot.scm')
-rwxr-xr-x[-rw-r--r--] | Biz/Bot.scm | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/Biz/Bot.scm b/Biz/Bot.scm index dec654c..c06c651 100644..100755 --- a/Biz/Bot.scm +++ b/Biz/Bot.scm @@ -1,14 +1,20 @@ +#!/usr/bin/env sh +exec guile -l $BIZ_ROOT/Biz/Bot.scm -e '(@ (Biz Bot) main)' -s "$0" "$@" +!# + + ;; Usage with ii: ;; ;; tail -f \#biz/out | guile -L $BIZ_ROOT -s Biz/Bot.scm -(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-module (Biz Bot) + #:use-module (ice-9 rdelim) + #:use-module (ice-9 match) + #:use-module (ice-9 regex) + #:use-module (ice-9 receive) + #:use-module (bs core) + #:use-module ((bs string) #:prefix string.) + #:export (main)) (define (log msg) (display msg (current-error-port))) @@ -39,17 +45,18 @@ (else (display (fmt "command not understood: ~a" msg)))))) -(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)) +(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))) |