It's a robot. Ash is a god damn robot!
A simple IRC bot, based on pircbotx, started as a fork of clj-irc.
Because I need one that works with grove.io, that is very simple, extensible, supports webhooks and has some simple persistance solution embedded.
See plugins for
examples. You can add your own event listeners by extending the qbits.ash.bot/listen
multimethod.
See echoweb for a basic example of webhook integration.
[cc.qbits/ash "0.2.6"]
(require
'[qbits.ash :as ash]
'[qbits.ash.webhooks :as webhooks]
'[qbits.ash.plugins.clojure :as clj]
'[qbits.ash.plugins.google :as goog]
'[qbits.ash.plugins.echoweb :as echoweb])
(-> (ash/make-bot :server-password "meh"
:nick "just-a-bot"
:name "just-a-bot"
:password "1234"
:host "meh.irc.grove.io"
:port 6667
:channels ["#foo" "#bar"]
:auto-reconnect true)
clj/handler
goog/handler
echoweb/handler)
(webhooks/start-server)
Plugins are very easy to implement:
(ns yourbot.plugins.meh
(:require [qbits.ash :as ash]))
(defn handler
[bot]
(ash/listen bot :on-message
(fn [event]
(when (re-find #"sayhi" (:content event))
;; reply knows about context form the event passed
;; (privmsg, channel msg, etc)
(ash/reply bot event "Hello world"))))))
For a webook:
(defn handler [bot]
(ash/listen bot :on-webhook
:post #"^/say-hi"
(fn [request]
(ash/send-message "#somechan" "hohai")))
(ash/listen bot :on-webhook
:get #"^/say-hi-foo"
(fn [request]
(ash/send-message "foo" "hohai foo")))
Because clojail employs the JVM's built in sandboxing, you'll need to have a ~/.java.policy file to define permissions for your own code. If you don't do this, you'll get security exceptions.
Copyright © 2012 FIXME
Distributed under the Eclipse Public License, the same as Clojure.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close