1 ! Copyright (C) 2009 Bruno Deferrari.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors irc.messages irc.messages.base kernel make
4 combinators sequences ;
5 IN: irc.logbot.log-line
7 : dot-or-parens ( string -- string )
8 [ "." ] [ " (" prepend ")." append ] if-empty ;
10 GENERIC: >log-line ( object -- line )
12 M: irc-message >log-line line>> ;
15 [ "CTCP: " % dup sender>> % " " % text>> % ] "" make ;
18 [ "* " % dup sender>> % " " % text>> % ] "" make ;
21 [ "<" % dup sender>> % "> " % text>> % ] "" make ;
23 : prefix% ( string -- )
26 M: irc.messages:join >log-line
29 [ prefix>> prefix% " has joined the channel." % ] bi
35 [ prefix>> prefix% " has left the channel" % ]
36 [ comment>> dot-or-parens % ] tri
42 [ prefix>> prefix% " has quit" % ]
43 [ comment>> dot-or-parens % ] tri
50 [ " has kicked " % user>> % ]
51 [ " from the channel" % comment>> dot-or-parens % ]
55 M: participant-mode >log-line
59 [ " has set mode " % mode>> % ]
60 [ " to " % parameter>> % ]
65 [ "* " % dup sender>> % " is now known as " % nickname>> % ] "" make ;
68 [ "* " % dup sender>> % " has set the topic for " % dup channel>> %
69 ": \"" % topic>> % "\"" % ] "" make ;