-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtyped-irc-example.rkt
33 lines (29 loc) · 1.19 KB
/
typed-irc-example.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#lang typed/racket
(require typed/irc
typed/irc/irc-message)
(define i : IRC (new irc%
[host "irc.anthrochat.org"]
[port 6697]
[nick "RachelRacket"]
[user "irc"]
[defaultmode 8]
[ssl #t]
[sasl #f] ; to enable sasl, set this and the other sasl related fields.
[sasl-username #f] ; set to a String containing your username
[sasl-password #f] ; set to a String containing your password
))
; todo: figure out why we can't cast our Async-Channel.
(define ircmsgs (send i hosepipe!))
(void (sync (send i ready?)))
(send i join "#thezoo")
(let loop ()
; todo: Fix this nasty syntax crap.
(define msg : IRC-Message (cast (sync ircmsgs) IRC-Message)); type is Evtof Any data is always IRC-Message
(display (send msg raw))
(cond
[(and (string=? (send msg verb) "PRIVMSG") (string=? (first
(string-split
(list-ref
(send msg args) 1))) "-hi" ))
(send i msg (list-ref (send msg args) 0) "Hoi!")])
(loop))