From 3c161b03249cd37b6476759564c16e39962e9253 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Sun, 12 Apr 2020 20:33:22 -0500 Subject: added a start-function that reads a config file to get started --- posterbot.lisp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'posterbot.lisp') 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))) -- cgit v1.2.3