1 ! Copyright (C) 2008, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: calendar debugger io io.encodings.utf8 io.launcher
4 irc.client irc.client.chats kernel make mason.common mason.git
5 math namespaces sequences threads timers ;
8 SYMBOL: nickserv-handle
9 SYMBOL: nickserv-password
11 : bot-profile ( -- obj )
12 "irc.libera.chat" 6697
13 nickserv-handle get "stackoid2" or
14 nickserv-password get <irc-profile> ;
16 : bot-channel ( -- seq ) "#concatenative" ;
18 GENERIC: handle-message ( msg -- )
20 M: object handle-message drop ;
22 : bot-loop ( chat -- )
23 dup hear handle-message bot-loop ;
25 : start-bot ( -- chat )
26 bot-profile <irc-client>
29 [ bot-channel <irc-channel-chat> dup ] dip
30 '[ _ [ _ attach-chat ] [ bot-loop ] bi ]
34 : git-log ( from to -- lines )
39 "--pretty=format:%h %an: %s" ,
42 utf8 [ read-lines ] with-process-reader ;
44 : updates ( from to -- lines )
46 dup length 4 > [ 4 head "... and more" suffix ] when ;
48 : report-updates ( from to chat -- )
50 [ 1 seconds sleep ] swap
51 '[ _ speak ] interleave ;
53 : check-for-updates ( chat -- )
56 { "git" "pull" "origin" "master" } short-running-process
63 '[ _ check-for-updates ] 5 minutes every drop ;