Paste: testbot

Author: tizoc
Mode: factor
Date: Thu, 9 Apr 2009 23:43:27
Plain Text |
USING: irc.client kernel threads fry alarms calendar prettyprint ;
IN: testbot

: bot-profile ( -- obj )
    "irc.freenode.org" 6667 "testbot" f <irc-profile> ;

: bot-channel ( -- seq ) "#testbot-test" ;

GENERIC: handle-message ( msg -- )
#! Changing the '.' to drop and doing a refresh-all doesn't stop the prettyprints
M: object handle-message . ;

: bot-loop ( chat -- )
    dup hear handle-message bot-loop ;

: start-bot ( -- chat )
    bot-profile <irc-client>
    [ connect-irc ]
    [
        [ bot-channel <irc-channel-chat> dup ] dip
        '[ _ [ _ attach-chat ] [ bot-loop ] bi ]
        "Testbot" spawn drop
    ] bi ;

: testbot ( -- )
    start-bot
    '[ _ drop ] 5 minutes every drop ;

MAIN: testbot

New Annotation

Summary:
Author:
Mode:
Body: