1 ! Copyright (C) 2009 Bruno Deferrari
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel fry splitting ascii accessors combinators
4 arrays classes.tuple math.order words assocs
5 irc.messages.base sequences ;
6 IN: irc.messages.parser
9 : split-at-first ( seq separators -- before after )
10 dupd '[ _ member? ] find [ cut rest ] [ swap ] if ;
12 ! ":ircuser!n=user@isp.net JOIN :#factortest"
13 : split-message ( string -- prefix command parameters trailing )
14 ":" ?head [ " " split1 ] [ f swap ] if
16 [ words harvest unclip swap ] dip ;
18 : sender ( irc-message -- sender )
19 prefix>> [ ":" ?head drop "!" split-at-first drop ] [ f ] if* ;
22 : string>irc-message ( string -- irc-message )
24 [ [ irc>type new ] [ >>command ] bi ]
28 [ prefix<< ] [ fill-irc-message-slots ] [ swap >>line ] tri