Paste: logger bot
Author: | tizoc |
Mode: | factor |
Date: | Tue, 14 Apr 2009 01:00:06 |
Plain Text |
USING: accessors fry io io.encodings.8-bit io.files irc.client
irc.client.chats irc.messages.base kernel threads ;
IN: irc.logbot
: bot-profile
"irc.freenode.org" 6667 "flogger" f <irc-profile> ;
: bot-channel "#concatenative" ;
: log-stream "/tmp/concatenative.log" latin1 <file-writer> ;
GENERIC: handle-message
M: object handle-message drop ;
M: irc-message handle-message line>> print flush ;
: (bot-loop) dup hear handle-message (bot-loop) ;
: bot-loop log-stream [ (bot-loop) ] with-output-stream ;
: start-bot
bot-profile <irc-client>
[ connect-irc ]
[
[ bot-channel <irc-channel-chat> ] dip
'[ _ [ _ attach-chat ] [ bot-loop ] bi ]
"LogBot" spawn drop
] bi ;
: logbot start-bot ;
MAIN: logbot
New Annotation