Skip to content

Instantly share code, notes, and snippets.

@funrep
Last active December 23, 2015 11:09
Show Gist options
  • Save funrep/6626802 to your computer and use it in GitHub Desktop.
Save funrep/6626802 to your computer and use it in GitHub Desktop.
irc bot probs
#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))
@funrep
Copy link
Author

funrep commented Sep 19, 2013

> (enter! "helloworld.rkt")
"helloworld.rkt"> (define-values (a b) (tcp-connec
t "irc.codetalk.io" 6667))
"helloworld.rkt"> (listen a b)                    
(:irc.codetalk.io NOTICE AUTH :*** Looking up your
 hostname...)
(:irc.codetalk.io NOTICE AUTH :*** Couldn't resolv
e your hostname; using your IP address instead)
(ERROR :Closing Link: [88.129.155.128] (Ping timeo
ut: 38 seconds))
; connection failed [,bt for context]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment