fix eval, prepare for multiple channels

master
opfez 2021-04-08 14:46:41 +00:00
parent 75f1f2f0a1
commit 022a90254f
1 changed files with 8 additions and 4 deletions

View File

@ -6,6 +6,7 @@
(ice-9 format))
(define +channel+ "#bots")
(define +channels+ '("#tildetown" "#bots"))
(define (scdr lst)
"Safe CDR which will return the empty list if it is passed the empty list instead of throwing an error."
@ -56,8 +57,11 @@
(define (send-user stream)
(format stream "USER anna 0.0.0.0 anna :Anna\r\n"))
(define (join-channel stream)
(format stream "JOIN ~a\r\n" +channel+))
(define (join-channels stream)
;; (for-each (lambda (chn)
;; (format stream "JOIN ~a\r\n" chn))
;; +channels+))
(format stream "JOIN ~a\r\n" "#bots"))
(define (send-message stream chn msg)
(format stream "PRIVMSG ~a :~a\r\n" chn msg))
@ -77,7 +81,7 @@
(equal? ":!anna" (slist-ref data 3)))
(send-message stream +channel+ "Hello! I respond to !rollcall, !anna, and !eval <s-expr>."))
((equal? ":!eval" (slist-ref data 3))
(let* ((expr (string-concatenate (intersperse " " (cdr (member ":eval" data))))))
(let* ((expr (string-concatenate (intersperse " " (cdr (member ":!eval" data))))))
(send-message stream +channel+ (eval (read (open-input-string expr))
(interaction-environment)))))
((and (= 7 (length data))
@ -90,6 +94,6 @@
(let* ((io (make-connection "127.0.0.1" 6667)))
(send-nick io)
(send-user io)
(join-channel io)
(join-channels io)
(main-loop io))