- (irc-format socket "PRIVMSG ~a :*stupid puppy look*" channel))))
- (_
- (cond
- (is-action
- (format #t "~a emoted ~s in channel ~a\n"
- speaker message channel))
- (else
- (format #t "~a said ~s in channel ~a\n"
- speaker message channel))))))
-
-(define main
- (make-irc-bot-cli (make-handle-line
- #:handle-privmsg (wrap-apply handle-message))))
+ (<- (actor-id irc-bot) 'send-line channel
+ "*stupid puppy look*"))))
+ ;; Otherwise... just spit the output to current-output-port or whatever
+ (_
+ (if emote?
+ (format #t "~a emoted ~s in channel ~a\n"
+ speaker line channel)
+ (format #t "~a said ~s in channel ~a\n"
+ speaker line channel)))))
+
+
+(define (display-help scriptname)
+ (format #t "Usage: ~a [OPTION] username" scriptname)
+ (display "
+ -h, --help display this text
+ --server=SERVER-NAME connect to SERVER-NAME
+ defaults to \"irc.freenode.net\"
+ --channels=CHANNEL1,CHANNEL2
+ join comma-separated list of channels on connect
+ defaults to \"##botchat\"")
+ (newline))
+
+(define (parse-args scriptname args)
+ (args-fold (cdr args)
+ (list (option '(#\h "help") #f #f
+ (lambda _
+ (display-help scriptname)
+ (exit 0)))
+ (option '("server") #t #f
+ (lambda (opt name arg result)
+ `(#:server ,arg ,@result)))
+ (option '("channels") #t #f
+ (lambda (opt name arg result)
+ `(#:channels ,(string-split arg #\,)
+ ,@result)))
+ (option '("repl") #f #t
+ (lambda (opt name arg result)
+ `(#:repl ,(or arg #t) ,@result))))
+ (lambda (opt name arg result)
+ (format #t "Unrecognized option `~a'\n" name)
+ (exit 1))
+ (lambda (option result)
+ `(#:username ,option ,@result))
+ '()))
+
+(define* (run-bot #:key (username "examplebot")
+ (server "irc.freenode.net")
+ (channels '("##botchat"))
+ (repl #f))
+ (run-hive
+ (lambda (hive)
+ (define irc-bot
+ (bootstrap-actor* hive <my-irc-bot> "irc-bot"
+ #:username username
+ #:server server
+ #:channels channels))
+ (define repl-manager
+ (cond
+ ((string? repl)
+ (bootstrap-actor* hive <repl-manager> "repl"
+ #:path repl))
+ (repl
+ (bootstrap-actor* hive <repl-manager> "repl"))))
+
+ (wait (make-condition)))))