Skip to content

A lightweight clojure wrapper around the smack jabber/XMPP library

Notifications You must be signed in to change notification settings

emlyn/quit-yo-jibber

This branch is 24 commits behind AdamClements/quit-yo-jibber:master.

Repository files navigation

Quit-yo-jibber Jabber library

The quit-yo-jibber jabber client is a clojure wrapper around jive software's smack talk xmpp library. Forked from xmpp-clj, this version aims to be more general, allowing for chat clients as well as chatbots.

Usage

Add quit-yo-jibber to your deps (project.clj):

[quit-yo-jibber "0.4.0"]

and use the main file

(ns my.namespace
    (:require [quit-yo-jibber :refer :all]))

Define your connection params (host, domain and port are optional arguments, but it defaults to gtalk settings):

;; Connection Info
(def connect-info {:username "[email protected]"
                   :password "*****"})

I recommend that you don't define these in code, but (read-string (slurp)) in a credentials file which you don't put into version control.

Create a function to respond to a message:

(defn handle-message [conn msg]
  (str "You said " (:body msg)))

Now make a connection with some callbacks defined (The var around handle-message means that you can re-define it and the underlying java listener will call your newly defined function, rather than staying on the old implementation):

(def conn (make-connection connect-info (var handle-message))

Next, fire up your chat client, add your new buddy, and send him a message. The response should look someting like this:

me: hello chatbot chatbot: You said hello chatbot

If you want to send a message unprompted, without first receiving one, you can use the send function like so:

(send conn "[email protected]" "I wouldn't like not to speak unless spoken to")

You can get roster information like so (see also the roster and available functions):

And you can test for online status and such with the online? and away? predicates like so:

(online? conn "[email protected]")
=> false ;; because it's a fake email address. Of course they're not online.

When you're done with a connection, you can log out and close it like so: (close-connection conn)

Problems?

Open up an issue

License

Eclipse Public License v1.0

About

A lightweight clojure wrapper around the smack jabber/XMPP library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Clojure 100.0%