1
0
Disbranĉigi 0

Add 'debug' option to irc:loop

This will print all messages received from IRC.
This commit is contained in:
Jaidyn Ann 2023-05-29 11:03:40 -05:00
parent bb80670a18
commit 77d741f598

View File

@ -28,7 +28,7 @@
(import scheme
(chicken base) (chicken condition) (chicken io) (chicken module)
(chicken string) (chicken tcp)
(chicken pretty-print) (chicken string) (chicken tcp)
srfi-1 srfi-19 srfi-69 srfi-130
openssl)
@ -551,18 +551,20 @@
;; Basic loop for using an IRC connection, using two hook functions:
;; (on-command connection command params sender tags)
;; (on-reply connection reply-code params sender tags)
(define (irc:loop connection on-command on-reply)
(define (irc:loop connection on-command on-reply #!optional (debug #f))
(let* ([output (irc:read-alist connection)]
[command (alist-ref 'command output)]
[reply (alist-ref 'reply output)]
[params (alist-ref 'params output)]
[sender (alist-ref 'sender output)]
[tags (alist-ref 'tags output)])
(if debug
(pretty-print output))
(if (and on-command command)
(apply on-command (list connection command params sender tags)))
(if (and on-reply reply)
(apply on-reply (list connection reply params sender tags)))
(irc:loop connection on-command on-reply)))
(irc:loop connection on-command on-reply debug)))
) ;; ircc module