40 lines
1.1 KiB
Common Lisp
40 lines
1.1 KiB
Common Lisp
|
(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*))
|