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
$ l | |
config.rkt eval.rkt main.rkt network.rkt parser.rkt README.md | |
$ raco exe main.rkt | |
$ ./main | |
standard-module-name-resolver: collection not found | |
collection: "racket/match" | |
in collection directories: | |
context...: | |
standard-module-name-resolver | |
#%embedded:g1705:parser: [running body] |
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 | |
(provide split-message | |
get-nick | |
get-host | |
get-chan | |
get-action) | |
(define (split-message s) | |
(let ([ss (regexp-split #rx":" s)]) |
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 (split-message s) | |
(let ([ss (regexp-split #rx":" s)]) | |
(match (regexp-split #rx":" s) | |
[(list " " _ ...) (cdr ss)] | |
[_ ss)]))) |
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
-> (regexp-match #rx"^(?:[:](\S+) )?(\S+)(?: (?!:)(.+?))?(?: [:](.+))?$" "PING :server.net") | |
; readline-input:1:17: read: unknown escape sequence \S in string [,bt for | |
; context] | |
#<procedure:+> | |
; readline-input:1:29: read: unexpected `)' [,bt for context] | |
; readline-input:1:31: read: unexpected `)' [,bt for context] | |
; ?: undefined; | |
; cannot reference undefined identifier | |
; [,bt for context] | |
; S+: undefined; |
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
-> (regexp-match #rx"a|b" "cat") | |
; |ab" "cat") | |
; (regexp-match #rx"ab|: undefined; | |
; cannot reference undefined identifier | |
; [,bt for context] | |
" " | |
; cat: undefined; | |
; cannot reference undefined identifier | |
; [,bt for context] |
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 |
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 (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 (getline in)) |
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))) | |
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 s (read-line in)) | |
(if (ping? s) | |
(pong s out) | |
'()) | |
(displayln s) | |
(listen in out))) |
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
// tror denna ska funka, kan ej C++ xD | |
int randR(unsigned int min, unsigned int max) { | |
int x = rand(); | |
if (RAND_MAX == x) return randR(min, max); | |
int range = max - min, | |
remainder = RAND_MAX % range, | |
bucket = RAND_MAX / range; | |