1 ! Copyright (C) 2009 Bruno Deferrari
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel fry splitting ascii calendar accessors combinators
4 arrays classes.tuple math.order words assocs strings irc.messages.base
5 combinators.short-circuit math ;
6 EXCLUDE: sequences => join ;
10 IRC: pass "PASS" password ;
11 IRC: nick "NICK" : nickname ;
12 IRC: user "USER" user mode _ : realname ;
13 IRC: oper "OPER" name password ;
14 IRC: mode "MODE" name mode parameter ;
15 IRC: service "SERVICE" nickname _ distribution type _ : info ;
16 IRC: quit "QUIT" : comment ;
17 IRC: squit "SQUIT" server : comment ;
19 IRC: join "JOIN" : channel ;
20 IRC: part "PART" channel : comment ;
21 IRC: topic "TOPIC" channel : topic ;
22 IRC: names "NAMES" channel ;
23 IRC: list "LIST" channel ;
24 IRC: invite "INVITE" nickname channel ;
25 IRC: kick "KICK" channel user : comment ;
27 IRC: privmsg "PRIVMSG" target : text ;
28 IRC: notice "NOTICE" target : text ;
30 IRC: motd "MOTD" target ;
31 IRC: lusers "LUSERS" mask target ;
32 IRC: version "VERSION" target ;
33 IRC: stats "STATS" query target ;
34 IRC: links "LINKS" server mask ;
35 IRC: time "TIME" target ;
36 IRC: connect "CONNECT" server port remote-server ;
37 IRC: trace "TRACE" target ;
38 IRC: admin "ADMIN" target ;
39 IRC: info "INFO" target ;
41 IRC: servlist "SERVLIST" mask type ;
42 IRC: squery "SQUERY" service-name : text ;
44 IRC: who "WHO" mask operator ;
45 IRC: whois "WHOIS" target mask ;
46 IRC: whowas "WHOWAS" nickname count target ;
48 IRC: kill "KILL" nickname : comment ;
49 IRC: ping "PING" server1 server2 ;
50 IRC: pong "PONG" server1 server2 ;
51 IRC: error "ERROR" : message ;
53 IRC: rpl-welcome "001" nickname : comment ;
54 IRC: rpl-whois-user "311" nicnamek user host _ : real-name ;
55 IRC: rpl-channel-modes "324" channel mode params ;
56 IRC: rpl-notopic "331" channel : topic ;
57 IRC: rpl-topic "332" channel : topic ;
58 IRC: rpl-inviting "341" channel nickname ;
59 IRC: rpl-names "353" nickname _ channel : nicks ;
60 IRC: rpl-names-end "366" nickname channel : comment ;
62 IRC: rpl-nickname-in-use "433" _ name ;
63 IRC: rpl-nick-collision "436" nickname : comment ;
65 PREDICATE: channel-mode < mode name>> first "#&" member? ;
66 PREDICATE: participant-mode < channel-mode parameter>> ;
67 PREDICATE: ctcp < privmsg
68 trailing>> { [ length 1 > ] [ first 1 = ] [ peek 1 = ] } 1&& ;
69 PREDICATE: action < ctcp trailing>> rest "ACTION" head? ;
71 M: rpl-names post-process-irc-message ( rpl-names -- )
72 [ [ blank? ] trim " " split ] change-nicks drop ;
74 M: ctcp post-process-irc-message ( ctcp -- )
75 [ rest but-last ] change-text drop ;
77 M: action post-process-irc-message ( action -- )
78 [ 7 tail ] change-text call-next-method ;