diff options
author | Colin Okay <cbeok@protonmail.com> | 2020-04-12 20:33:22 -0500 |
---|---|---|
committer | Colin Okay <cbeok@protonmail.com> | 2020-04-12 20:33:22 -0500 |
commit | 3c161b03249cd37b6476759564c16e39962e9253 (patch) | |
tree | cbe87536b78cc75720c8f0e1dc4752f316c66aa8 | |
parent | 0806b9474a8bd882b39f73c85a3bd24713c62bdf (diff) |
added a start-function that reads a config file to get started
-rw-r--r-- | posterbot.lisp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/posterbot.lisp b/posterbot.lisp index 92e6d76..ec604f4 100644 --- a/posterbot.lisp +++ b/posterbot.lisp @@ -53,3 +53,22 @@ is, downloads the image and posts it to the current room." ;; posting any images found to the room at the current *ROOM-ID* (defmethod handle-event :after ((*posterbot* posterbot) (event text-message-event)) (mapc #'handle-link-candiate (ppcre:split " " (msg-body event)))) + + +(defun start-posterbot () + "A start function to pass in as the :toplevel to SAVE-LISP-AND-DIE" + (let* ((config (if (uiop:file-exists-p "posterbot.config") + (with-open-file (input "posterbot.config") + (read input)) + (progn (format t "I think you need a posterbot.config~^") + (return-from start-posterbot)))) + (bot (make-instance 'posterbot + :ssl (if (member :ssl config) + (getf config :ssl) + t) + :hardcopy (getf config :hardcopy) + :user-id (gerf config :user-id) + :homeserver (getf config :homeserver)))) + (when (not (logged-in-p bot)) + (login bot (getf config :user-id) (getf config :password))) + (start bot))) |