]> gitweb.factorcode.org Git - factor.git/blob - extra/irc/logbot/log-line/log-line.factor
irc.logbot: Format for actions
[factor.git] / extra / irc / logbot / log-line / log-line.factor
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 EXCLUDE: sequences => join ;
5 IN: irc.logbot.log-line
6
7 : dot-or-parens ( string -- string )
8     [ "." ] [ " (" prepend ")." append ] if-empty ;
9
10 GENERIC: >log-line ( object -- line )
11
12 M: irc-message >log-line line>> ;
13
14 M: ctcp >log-line
15     [ "CTCP: " % dup sender>> % " " % text>> % ] "" make ;
16
17 M: action >log-line
18     [ "* " % dup sender>> % " " % text>> % ] "" make ;
19
20 M: privmsg >log-line
21     [ "<" % dup sender>> % "> " % text>> % ] "" make ;
22
23 M: join >log-line
24     [ "* " % sender>> % " has joined the channel." % ] "" make ;
25
26 M: part >log-line
27     [ "* " % dup sender>> % " has left the channel" %
28       comment>> dot-or-parens % ] "" make ;
29
30 M: quit >log-line
31     [ "* " % dup sender>> % " has quit" %
32       comment>> dot-or-parens % ] "" make ;
33
34 M: kick >log-line
35     [ "* " % dup sender>> % " has kicked " % dup user>> %
36       " from the channel" % comment>> dot-or-parens % ] "" make ;
37
38 M: participant-mode >log-line
39     [ "* " % dup sender>> % " has set mode " % dup mode>> %
40       " to " % parameter>> % ] "" make ;
41
42 M: nick >log-line
43     [ "* " % dup sender>> % " is now known as " % nickname>> % ] "" make ;
44
45 M: topic >log-line
46     [ "* " % dup sender>> % " has set the topic for " % dup channel>> %
47       ": \"" % topic>> % "\"" % ] "" make ;