1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: fry irc.client irc.client.chats kernel namespaces
4 sequences threads io.encodings.8-bit io.launcher io splitting
5 make mason.common mason.updates calendar math alarms ;
8 : bot-profile ( -- obj )
9 "irc.freenode.org" 6667 "jackass" f <irc-profile> ;
11 : bot-channel ( -- seq ) "#concatenative" ;
13 GENERIC: handle-message ( msg -- )
15 M: object handle-message drop ;
17 : bot-loop ( chat -- )
18 dup hear handle-message bot-loop ;
20 : start-bot ( -- chat )
21 bot-profile <irc-client>
24 [ bot-channel <irc-channel-chat> dup ] dip
25 '[ _ [ _ attach-chat ] [ bot-loop ] bi ]
29 : git-log ( from to -- lines )
33 "--pretty=format:%h %an: %s" ,
36 latin1 [ lines ] with-process-reader ;
38 : updates ( from to -- lines )
40 dup length 4 > [ 4 head "... and more" suffix ] when ;
42 : report-updates ( from to chat -- )
44 [ 1 seconds sleep ] swap
45 '[ _ speak ] interleave ;
47 : check-for-updates ( chat -- )
48 [ git-id git-pull-cmd short-running-process git-id ] dip
53 '[ _ check-for-updates ] 5 minutes every drop ;