Thanks for your quick answer. On May 1, 3:53 pm, Christophe Grand <christo...@cgrand.net> wrote:
> > Whate are you trying to achieve? > I'll try to clarify my problem. I'm a newcomer to clojure (enthusiast about it) and I'm working on small project to get familiar with clojure. The idea consist of making a jabber bot that would allow me to remotely execute clojure code from a jabber account(Jabber is an instant messaging protocol). It would be kind of a remote repl. This way I could set the bot running on my personal computer and could access it from school, or any computer that i don't own. So that I could experiment with the repl at school where i don't have the right to install anything on their machine. I need to access to a local binding because I must put the (eval (read- string code)) into a messageListener method. I can execute clojure code remotely over jabber but I want the bot to send me back the output of a form. And for that I think I need to refer to the chat connection instance. Here's the code so far: (ns replbot.main) (import '(org.jivesoftware.smack XMPPConnection ConnectionConfiguration SASLAuthentication MessageListener ChatManagerListener)) (def mess "Test from Clojure!!") (def connection (new org.jivesoftware.smack.XMPPConnection (new ConnectionConfiguration "jabber.org" 5222 "jabber.org"))) (defn main [] (. connection connect) (. SASLAuthentication supportSASLMechanism "PLAIN" 0) (. connection login "nakyssjabbertest" "testjabber") (.. connection (getChatManager) (addChatListener (proxy [ChatManagerListener] [] (chatCreated [chat1 created] (. chat1 addMessageListener (proxy [MessageListener] [] (processMessage [chat2 message] (do (. chat2 sendMessage "trying to...") (let [chat chat2 test001 "test001"] (binding [*ns* (the-ns 'replbot.main)] (eval (read-string (. message getBody) )) ) ) (. chat2 sendMessage "done.") ) ) ) ))))) ) (main) The processMessage method takes a chat argument, i need to be able to refer to it from the (eval (read-string "")) call to get a feedback. for exemple (let [chat chat2 test001 "test001"] (binding [*ns* (the-ns 'replbot.main)] ;;; getBody could be : (some code ....) (def feedback (...)) (. chat sendMessage feedback) (eval (read-string (. message getBody) )) ) ) I don't fully understand the function to explicitly pass argument. Could you clarify Christophe ? Does anyone have any thought? I would appreciate. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---