diff options
author | Tom Willemse | 2013-04-23 01:08:09 +0200 |
---|---|---|
committer | Tom Willemse | 2013-04-23 01:08:09 +0200 |
commit | fdac91a140a849953f9c54c68aac65e5f6e83c84 (patch) | |
tree | 5df80755867d903730834e1674c2710d32ca5984 /lisp | |
download | sil-fdac91a140a849953f9c54c68aac65e5f6e83c84.tar.gz sil-fdac91a140a849953f9c54c68aac65e5f6e83c84.zip |
Initial commit
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/.gitignore | 1 | ||||
-rw-r--r-- | lisp/Makefile | 40 | ||||
-rw-r--r-- | lisp/make-image.lisp | 35 | ||||
-rw-r--r-- | lisp/package.lisp | 21 | ||||
-rw-r--r-- | lisp/sil.asd | 33 | ||||
-rw-r--r-- | lisp/sil.lisp | 96 |
6 files changed, 226 insertions, 0 deletions
diff --git a/lisp/.gitignore b/lisp/.gitignore new file mode 100644 index 0000000..7391de6 --- /dev/null +++ b/lisp/.gitignore @@ -0,0 +1 @@ +sil diff --git a/lisp/Makefile b/lisp/Makefile new file mode 100644 index 0000000..274338f --- /dev/null +++ b/lisp/Makefile @@ -0,0 +1,40 @@ +# Copyright (C) 2013 Tom Willemsen <tom at ryuslash dot org> +# +# This file is part of Sil +# +# Sil is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Sil is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Sil. If not, see <http://www.gnu.org/licenses/>. +DESTDIR ?= /usr/local +LISP = sbcl --disable-debugger + +binaries = sil +install-binaries = $(addprefix install-,$(binaries)) +uninstall-binaries = $(addprefix uninstall-,$(binaries)) + +.PHONY: all install $(install-binaries) uninstall $(uninstall-binaries) \ + install-strip + +all: $(binaries) +install: $(install-binaries) +uninstall: $(uninstall-binaries) +install-strip: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install + +$(install-binaries): install-%: % + $(INSTALL_PROGRAM) $* "$(DESTDIR)/bin/$*" + +$(uninstall-binaries): uninstall-%: + rm -f "$(DESTDIR)/bin/$*" + +sil: sil.lisp make-image.lisp + $(LISP) --load make-image.lisp diff --git a/lisp/make-image.lisp b/lisp/make-image.lisp new file mode 100644 index 0000000..a3b40f9 --- /dev/null +++ b/lisp/make-image.lisp @@ -0,0 +1,35 @@ +;; Copyright (C) 2013 Tom Willemsen <tom at ryuslash dot org> + +;; This file is part of Sil + +;; Sil is free software: you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; Sil is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with Sil. If not, see <http://www.gnu.org/licenses/>. + +;;; Code: + +#-sbcl +(error "This lisp implementation is not supported.") + +(require 'asdf) +(require 'sqlite) +(require 'mcclim) + +(asdf:oos 'asdf:load-op 'sil) + +(save-lisp-and-die + "sil" :toplevel + (lambda () + (sb-posix:putenv (format nil "SBCL_HOME=~A" #.(sb-ext:posix-getenv "SBCL_HOME"))) + (org.ryuslash.sil:sil sb-ext:*posix-argv*) + 0) + :executable t) diff --git a/lisp/package.lisp b/lisp/package.lisp new file mode 100644 index 0000000..7b9c136 --- /dev/null +++ b/lisp/package.lisp @@ -0,0 +1,21 @@ +;; Copyright (C) 2013 Tom Willemsen <tom at ryuslash dot org> + +;; This file is part of Sil + +;; Sil is free software: you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; Sil is distributed in the hope that it will be useful, but WITHOUT +;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +;; License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with Sil. If not, see <http://www.gnu.org/licenses/>. + +;;; Code: + +(defpackage :org.ryuslash.sil + (:use :cl :xmpp)) diff --git a/lisp/sil.asd b/lisp/sil.asd new file mode 100644 index 0000000..1275b4d --- /dev/null +++ b/lisp/sil.asd @@ -0,0 +1,33 @@ +;; Copyright (C) 2013 Tom Willemsen <tom at ryuslash dot org> + +;; This file is part of Sil + +;; Sil is free software: you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; Sil is distributed in the hope that it will be useful, but WITHOUT +;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +;; License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with Sil. If not, see <http://www.gnu.org/licenses/>. + +;;; Code: + +(defpackage :sil-system + (:use :cl :asdf)) +(in-package :sil-system) + +(defsystem :sil + :name "Sil" + :author "Tom Willemsen <tom@ryuslash.org>" + :version "0.1.0" + :maintainer "Tom Willemsen <tom@ryuslash.org>" + :description "A silly jabber bot." + :serial t + :depends-on (:cl-xmpp) + :components ((:file "package") + (:file "sil"))) diff --git a/lisp/sil.lisp b/lisp/sil.lisp new file mode 100644 index 0000000..cc02148 --- /dev/null +++ b/lisp/sil.lisp @@ -0,0 +1,96 @@ +;; Copyright (C) 2013 Tom Willemsen <tom at ryuslash dot org> + +;; This file is part of Sil + +;; Sil is free software: you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; Sil is distributed in the hope that it will be useful, but WITHOUT +;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +;; License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with Sil. If not, see <http://www.gnu.org/licenses/>. + +;;; Code: + +(in-package :org.ryuslash.sil) + +(require 'cl-xmpp-tls) + +(export '(sil)) + +(defvar *connection* nil + "The connection to the jabber server.") + +(defvar *host* "ryuslash.org" + "The host to log-in on.") + +(defvar *username* "sil" + "The username to log-in with, should not contain the jabber host.") + +(defvar *password* "tomtom" + "The password to log-in with.") + +(defvar *resource* "test" + "The resource to use when logging in.") + +(defvar *muc-rooms-alist* '("aethon@muc.ryuslash.org/sil") + "Any MUCs to join.") + +(defvar *jid* "sil@ryuslash.org/test" + "The JID used.") + +(defun get-rc-location () + "Get the location of the RC file." + (let ((xdg (sb-ext:posix-getenv "XDG_DATA_HOME")) + (home (sb-ext:posix-getenv "HOME"))) + (pathname + (apply 'concatenate 'string + (or xdg home) + (unless xdg "/.config") + '("/sil/rc.lisp"))))) + +(defun get-response (message) + (cond + ((string-equal (body message) "date") + (multiple-value-bind (second minute hour date month year day + daylight-p zone) (get-decoded-time) + (declare (ignore day daylight-p zone)) + (format nil "Date: ~D-~D-~D ~D:~D:~D" date month year hour + minute second))) + (t (format nil "auto-reply to: ~A" (from message))))) + +(defmethod handle ((connection connection) (message message)) + (if (string-equal (type- message) "groupchat") + (when (string-equal (body message) "," :end1 1) + (setf (body message) (subseq (body message) 1)) + (xmpp:message connection "aethon@muc.ryuslash.org" + (get-response message) :type :groupchat)) + (xmpp:message connection (from message) (get-response message)))) + +(defun load-rc () + "Load the RC file." + (let ((*package* (in-package :org.ryuslash.sil))) + (load (get-rc-location) :if-does-not-exist nil))) + +(defun receive () + (format t "Recieving~%") + (handler-case (receive-stanza-loop *connection*) + (simple-error () (receive)))) + +(defun sil (args) + (handler-case + (progn + (load-rc) + (setf *connection* (connect-tls :hostname *host*)) + (auth *connection* "sil" "tomtom" "test") + (map nil (lambda (ms) + (join-chatroom *connection* :room ms :from *jid*)) + *muc-rooms-alist*) + (receive)) + (sb-sys:interactive-interrupt () (format t "No! Don't leave me. *sob*~%"))) + (disconnect *connection*)) |