Created
September 20, 2013 12:35
-
-
Save funrep/6636805 to your computer and use it in GitHub Desktop.
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 connect (lambda () ( | |
(let-values ([(in out) (tcp-connect "irc.codetalk.io" 6667)]) | |
(begin | |
(displayln "NICK tob" out) | |
(displayln "USER tob 8 * : tob the bot" out) | |
(listen in out)))))) | |
(define (listen in out) (begin | |
(define ss (get-line in)) | |
(if (ping? ss) | |
(begin (pong ss out) (displayln "ponging")) | |
'()) | |
(displayln ss) | |
(listen in out))) | |
(define (get-line 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 20, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment