From 310275abdc61130c8cc77f7827163f136d57b63f Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 7 Jun 2021 13:41:53 -0400 Subject: Make executable --- Biz/Bot.scm | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) mode change 100644 => 100755 Biz/Bot.scm (limited to 'Biz/Bot.scm') diff --git a/Biz/Bot.scm b/Biz/Bot.scm old mode 100644 new mode 100755 index dec654c..c06c651 --- 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))) -- cgit v1.2.3