Last active
December 23, 2015 11:09
-
-
Save funrep/6626802 to your computer and use it in GitHub Desktop.
irc bot probs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define (listen in out) (begin | |
(define ss (getline in)) | |
(if (ping? ss) | |
(begin (pong ss out) (displayln "ponging")) | |
'()) | |
(displayln ss) | |
(listen in out))) | |
(define (getline in) | |
(let ([s (read-line in)]) | |
(if (eof-object? s) | |
(error "connection failed") | |
(string-split s)))) | |
(define (ping? ss) (eq? (car ss) "PING")) | |
(define (pong ss out) | |
(displayln (string-append "PONG " (car (cdr ss))) out)) |
Author
funrep
commented
Sep 19, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment