Home

Awesome

Jabberjay Build Status

<img src="misc/jabberjay.png" width="300" height="300" align="right" style="margin-left: 15px" />

Jabberjays are a type of muttation that consist of all male birds that were created in the Capitol labs to spy on enemies and rebels of the Capitol. Jabberjays had the ability to memorize and repeat entire human conversations, and were used as spies, to gather words and information. - The Hunger Games

Jabberjay is a Clojure micro-framework for creating Jabber bots.

Programming your own Jabber bot can be helpful and fun. You can use your Jabber bot to provide information about some running systems or to make your services interact with users.

Configuration

Default configuration is stored in project resources (config.edn) in EDN format:

{:jabber {:username "Fill me up!"
          :password "Fill me up!"
          :host "Fill me up!"
          :domain "Fill me up!"}
 :scripts {:folder "scripts"
           :watchdog 1000}}

Before using, it is necessary to configure the following parameters:

It is also possbile to use user-base configuration file, which should be located in ~/jabberjay.edn. All parameters from this file override default config parameters.

Development

To develop Jabber command, you need to create Clojure file in the script :folder. When :watchdog parameter is defined, then FS watchdog will check changes and reload scripts in runtime each N milliseconds. It could be useful in development mode, but you can switch if off in production mode (using :watchdog equals 0).

It is necessary to follow several rules during Jabber command development:

Script context

Each script receives context parameters, for example:

{:subject nil
 :from "bauer.vlad@gmail.com/gmail.3167A379"
 :to "jabberjay@gmail.com"
 :thread nil
 :error nil
 :packet-id "5A19D18217BBD43_1"
 :type :chat
 :from-name "bauer.vlad@gmail.com"
 :body "Hi Bot"
 :text "Bot"}

Example

This simple command always returns "Hello, your jabber account", when client sends "Hi" ("HI", "hi", "hI"):

(ns hi)

(defn init
  "Simple module for greating"
  [data]
  (str "Hello, " (or (:from-name data)
                     (:from data))))

Another example: scripts/weather.clj.

Usage

To grab a JAR from latest release:

curl -L -O https://github.com/vbauer/jabberjay/releases/download/0.2.0/jabberjay.jar

To build executable JAR from sources:

lein do clean, uberjar

To run the bot, simply do:

java -jar target/jabberjay.jar &

Might also like

License

Copyright © 2015 Vladislav Bauer

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

See LICENSE for more details.