summaryrefslogtreecommitdiffstats
path: root/xmpp-send.lisp
blob: 7c0a53032182c7dda0e6aea7e64d3f9623e61305 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(in-package :org.ryuslash.xmpp-send)

(defvar *connection* nil
  "The connection to the jabber server.")

(defvar *host* nil
  "The host to log-in on.")

(defvar *username* nil
  "The username to log-in with, should not contain the jabber host.")

(defvar *password* nil
  "The password to log-in with.")

(defvar *resource* nil
  "The resource to use when logging in.")

(defun get-rc-location ()
  "Get the location of the RC file."
  (let ((xdg (sb-ext:posix-getenv "XDG_CONFIG_HOME"))
        (home (sb-ext:posix-getenv "HOME")))
    (pathname
     (apply 'concatenate 'string
            (or xdg home)
            (unless xdg "/.config")
            '("/xmpp-send/rc.lisp")))))

;; (defun send (args)
;;   (handler-case (message *connection* (car args) (cadr args))))

(defun xmpp-send (args)
  ;; Load init file
  (let ((*package* (in-package :org.ryuslash.xmpp-send)))
    (load (get-rc-location) :if-does-not-exist nil))

  (setf *connection* (connect-tls :hostname *host*))
  (auth *connection* *username* *password* *resource*)
  (xmpp:message *connection* (cadr args) (caddr args) :type :chat)
  (disconnect *connection*))