USING: kernel io io.sockets io.encodings.ascii threads fry namespaces sequences splitting lists ; IN: fircey TUPLE: irc-message source command args longarg ; : ( source command args longarg -- irc-message ) irc-message boa ; : split-up-irc-string ( string -- args longarg ) ":" split1 [ nil ] unless* swap " " split "" swap remove swap ; : parse-irc-message ( string -- irc-message ) ":" ?head [ split-up-irc-string swap unclip swap swapd unclip swap swapd swap ] [ split-up-irc-string swap nil swap swapd unclip swap swapd swap ] if ; : login ( -- ) "NICK fircey" print "USER fircey fircey fircey fircey" print flush ; : bot-handler ( stdout -- ) [ dupd swap stream-print flush ] each-line drop ; : bot-connection ( -- ) "irc.freenode.net" 6667 ascii output-stream get '[ login _ bot-handler ] with-client ;