;; @@: Should we add a stop action?
#:init-value (build-actions
(*cleanup* repl-manager-cleanup)
- (init repl-manager-init))))
+ (*init* repl-manager-init))))
(define (repl-manager-cleanup repl-manager message)
;; Close the socket, if open
(while (actor-alive? repl-manager)
(poll-coop-repl-server server)
(8sleep (repl-manager-poll-every repl-manager))))
-
(socket #:accessor irc-bot-socket)
(actions #:allocation #:each-subclass
#:init-value (build-actions
- (init irc-bot-init)
+ (*init* irc-bot-init)
+ (*cleanup* irc-bot-cleanup)
(main-loop irc-bot-main-loop)
(send-line irc-bot-send-line-action))))
(<- (actor-id irc-bot) 'main-loop))
+(define (irc-bot-cleanup irc-bot message)
+ (close (irc-bot-socket irc-bot)))
+
(define (irc-bot-main-loop irc-bot message)
(define socket (irc-bot-socket irc-bot))
(define line (string-trim-right (read-line socket) #\return))
(repl
(bootstrap-actor* hive <repl-manager> "repl"))))
- (define initial-messages
- (if repl
- (list (bootstrap-message hive irc-bot 'init)
- (bootstrap-message hive repl-manager 'init))
- (list (bootstrap-message hive irc-bot 'init))))
-
;; TODO: load REPL
- (run-hive hive initial-messages))
+ (run-hive hive '()))
(define (main args)
(define parsed-args (parse-args "ircbot.scm" args))
#:username username
#:server server
#:channels channels))
- (run-hive hive (list (bootstrap-message hive irc-bot 'init))))
+ (run-hive hive '()))
#+END_SRC
Actors are connected to something called a "hive", which is a
(bootstrap-actor* hive <repl-manager> "repl"
#:path repl-path))
- (run-hive hive (list (bootstrap-message hive irc-bot 'init)
- (bootstrap-message hive repl-manager 'init))))
+ (run-hive hive '()))
#+END_SRC
If we put a call to run-bot at the bottom of our file we can call it,