summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Shangreaux <shshoshin@protonmail.com>2020-04-20 09:47:00 -0500
committerGrant Shangreaux <shshoshin@protonmail.com>2020-04-20 09:47:00 -0500
commitd920b0ef0099834a8c66b288560b3108137c862b (patch)
treec13d4f0e770607352a5c161c928cbb517adcd734
parent72c0386abe44180af41621d0556828bf8022f775 (diff)
Add: code to start up a bot when building an executable version
-rw-r--r--snekeyes.lisp18
1 files changed, 18 insertions, 0 deletions
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)))