Paste: bot src
Author: | slava |
Mode: | factor |
Date: | Tue, 2 Dec 2008 03:46:26 |
Plain Text |
USING: fry irc.client irc.client.private kernel namespaces
sequences threads io.encodings.8-bit io.launcher io splitting
make mason.common mason.updates calendar ;
IN: irc.gitbot
: bot-profile
"irc.freenode.org" 6667 "jackass" f <irc-profile> ;
: bot-channel "#concatenative" ;
: bot-loop
dup hear drop bot-loop ;
: start-bot
bot-profile <irc-client>
[ connect-irc ]
[
[ bot-channel <irc-channel-chat> dup ] dip
'[ _ [ _ attach-chat ] [ bot-loop ] bi ]
"GitBot" spawn drop
] bi ;
: git-log
[ "git-log" , "--no-merges" , "--pretty=format:%h %an: %s" , ".." swap 3append , ] { } make
latin1 [ input-stream get lines ] with-process-reader ;
: report-updates
[ git-log ] dip [ 3 seconds sleep ] swap '[ _ speak ] interleave ;
: check-for-updates
[ git-id git-pull-cmd short-running-process git-id ] dip
report-updates ;
Author: | slava |
Mode: | factor |
Date: | Tue, 2 Dec 2008 04:19:39 |
Plain Text |
USING: fry irc.client irc.client.private kernel namespaces
sequences threads io.encodings.8-bit io.launcher io splitting
make mason.common mason.updates calendar math alarms ;
IN: irc.gitbot
: bot-profile
"irc.freenode.org" 6667 "jackass" f <irc-profile> ;
: bot-channel "#concatenative" ;
GENERIC: handle-message
M: object handle-message drop ;
: bot-loop
dup hear handle-message bot-loop ;
: start-bot
bot-profile <irc-client>
[ connect-irc ]
[
[ bot-channel <irc-channel-chat> dup ] dip
'[ _ [ _ attach-chat ] [ bot-loop ] bi ]
"GitBot" spawn drop
] bi ;
: git-log
[
"git-log" ,
"--no-merges" ,
"--pretty=format:%h %an: %s" ,
".." swap 3append ,
] { } make
latin1 [ input-stream get lines ] with-process-reader ;
: updates
git-log reverse
dup length 4 > [ 4 head "... and more" suffix ] when ;
: report-updates
[ updates ] dip
[ 1 seconds sleep ] swap
'[ _ speak ] interleave ;
: check-for-updates
[ git-id git-pull-cmd short-running-process git-id ] dip
report-updates ;
: bot
start-bot
'[ _ check-for-updates ] 5 minutes every ;
New Annotation