From d920b0ef0099834a8c66b288560b3108137c862b Mon Sep 17 00:00:00 2001 From: Grant Shangreaux Date: Mon, 20 Apr 2020 09:47:00 -0500 Subject: Add: code to start up a bot when building an executable version --- snekeyes.lisp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/snekeyes.lisp b/snekeyes.lisp index c55dbac..220396b 100644 --- a/snekeyes.lisp +++ b/snekeyes.lisp @@ -84,3 +84,21 @@ (total (+ (car die-1) (car die-2))) (result (if (= 7 total) "Lucky 7! You win!" "Better luck next time..."))) (format nil "You rolled ~a ~a. ~a" (cdr die-1) (cdr die-2) result))) + +(defun start-snekeyes () + "A start function to pass in as the :toplevel to SAVE-LISP-AND-DIE" + (let* ((config (if (uiop:file-exists-p "snekeyes.config") + (with-open-file (input "snekeyes.config") + (read input)) + (progn (format t "I think you need a snekeyes.config~%~%") + (return-from start-snekeyes)))) + (bot (make-instance 'snekeyes + :ssl (if (member :ssl config) + (getf config :ssl) + t) + :hardcopy (getf config :hardcopy) + :user-id (getf config :user-id) + :homeserver (getf config :homeserver)))) + (when (not (logged-in-p bot)) + (login bot (getf config :user-id) (getf config :password))) + (start bot))) -- cgit v1.2.3