From 59895afcba08dcd55722e092e35c75e329471190 Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Tue, 29 Mar 2016 01:23:18 +0700 Subject: [PATCH] [#159] Housekeeping --- project.clj | 3 +- .../timbre/appenders/3rd_party/slack.clj | 30 ++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/project.clj b/project.clj index 53e599a..3bc203b 100644 --- a/project.clj +++ b/project.clj @@ -34,7 +34,8 @@ [com.taoensso/carmine "2.12.2"] [com.draines/postal "1.11.4"] [irclj "0.5.0-alpha4"] - [org.graylog2/gelfclient "1.3.1"]]} + [org.graylog2/gelfclient "1.3.1"] + [org.julienxx/clj-slack "0.5.3"]]} :dev [:1.7 :test {:dependencies [[org.clojure/clojurescript "1.7.28"]] diff --git a/src/taoensso/timbre/appenders/3rd_party/slack.clj b/src/taoensso/timbre/appenders/3rd_party/slack.clj index 6518e47..1f52b18 100644 --- a/src/taoensso/timbre/appenders/3rd_party/slack.clj +++ b/src/taoensso/timbre/appenders/3rd_party/slack.clj @@ -1,28 +1,30 @@ (ns taoensso.timbre.appenders.3rd-party.slack + "Requires https://github.com/julienXX/clj-slack" {:author "Simon Belak (@sbelak)"} - (:require (taoensso [timbre :as timbre] - [encore :as encore]) - (clj-slack [chat :as slack.chat] - [core :as slack]))) + (:require + [taoensso.timbre :as timbre] + [taoensso.encore :as enc] + [clj-slack.chat :as slack.chat] + [clj-slack.core :as slack])) (defn slack-appender - "Return Slack appender. - Required params: - `token` - Slack API token. See: Browse apps > Custom Integrations > Bots - `channel` - Channel ID. + "Returns Slack appender. Required params: + `token` - Slack API token. See: Browse apps > Custom Integrations > Bots + `channel` - Channel ID - Optional params: same as clj-slack.chat/post-message `optionals`. See: http://julienblanchard.com/clj-slack/clj-slack.chat.html" + Optional params: same as `clj-slack.chat/post-message` `optionals`, + Ref. http://julienblanchard.com/clj-slack/clj-slack.chat.html" [& [opts]] (let [{:keys [token channel]} opts conn {:api-url "https://slack.com/api" :token token}] - {:enabled? true - :async? true + {:enabled? true + :async? true :min-level nil - :rate-limit [[1 (encore/ms :secs 1)]] - :output-fn :inherit + :rate-limit [[1 (enc/ms :secs 1)]] + :output-fn :inherit :fn (fn [data] (let [{:keys [output-fn]} data] (slack.chat/post-message conn channel (output-fn data) - (dissoc opts :token :channel))))})) + (dissoc opts :token :channel))))}))