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