Skip to content

Commit

Permalink
Add swank support.
Browse files Browse the repository at this point in the history
  • Loading branch information
drewr committed Aug 21, 2009
1 parent 6a893da commit 902272d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions ivy.xml
Expand Up @@ -16,5 +16,6 @@
<dependency name="commons-logging" rev="1.1.1"/>
<dependency name="ezmorph" rev="1.0.5"/>
<dependency name="json-lib" rev="2.2.2-jdk15"/>
<dependency name="swank" rev="20090804201540+bfb55c4"/>
</dependencies>
</ivy-module>
2 changes: 2 additions & 0 deletions src/com/draines/clot/irc.clj
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion src/com/draines/clot/main.clj
@@ -1,19 +1,34 @@
(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!)
(clot/register-handler 'com.draines.clot.handlers.google)
(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))))))

0 comments on commit 902272d

Please sign in to comment.