From 902272d69133e88b28147407e089733292511af8 Mon Sep 17 00:00:00 2001 From: Drew Raines Date: Fri, 21 Aug 2009 13:24:28 -0500 Subject: [PATCH] Add swank support. --- ivy.xml | 1 + src/com/draines/clot/irc.clj | 2 ++ src/com/draines/clot/main.clj | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ivy.xml b/ivy.xml index 413e2d8..121309c 100644 --- a/ivy.xml +++ b/ivy.xml @@ -16,5 +16,6 @@ + diff --git a/src/com/draines/clot/irc.clj b/src/com/draines/clot/irc.clj index c488750..914c79a 100644 --- a/src/com/draines/clot/irc.clj +++ b/src/com/draines/clot/irc.clj @@ -493,6 +493,8 @@ :channels channels :password password})] (log conn (format "log-in: logging in to %s" host port)) + (when-not conn + (System/exit 1)) (when conn (register-connection conn) (when password diff --git a/src/com/draines/clot/main.clj b/src/com/draines/clot/main.clj index 80e5638..1fa708f 100644 --- a/src/com/draines/clot/main.clj +++ b/src/com/draines/clot/main.clj @@ -1,7 +1,9 @@ (ns com.draines.clot.main (:gen-class) (:require [com.draines.clot.irc :as clot] - [clojure.contrib.str-utils :as str-utils])) + [clojure.contrib.str-utils :as str-utils]) + (:use [swank.swank :only [ignore-protocol-version start-server]] + [clojure.main :only [repl]])) (defn setup! [] (clot/start-watcher!) @@ -9,11 +11,24 @@ (clot/register-handler 'com.draines.clot.handlers.tumblr) (clot/register-handler 'com.draines.clot.handlers.bandname)) +(defn swank! [port] + (let [stop (atom false)] + (repl :read (fn [rprompt rexit] + (if @stop + rexit + (do + (swap! stop (fn [_] true)) + `(do + (ignore-protocol-version "2009-02-24") + (start-server "/tmp/slime-port.txt" :encoding "iso-latin-1-unix" :port ~port))))) + :need-prompt #(identity false)))) + (defn -main [host port nick password & channels] (let [port (Integer/parseInt port) password (when-not (= "nil" password) password) channels (str-utils/re-split #" " (first channels))] (setup!) + (swank! 14005) (let [c (clot/log-in host port nick channels password)] (Thread/sleep 3000) (clot/log c (format "connection errors: %s" (clot/connection-agent-errors c))))))