 (ns panpan.eina
   (:require
+    [clojure.string    :as str]
     [panpan.github.rss :as rss]
     [jubot.adapter     :as ja]
     [jubot.scheduler   :as js]

(def ^:const NAME "エイナ")
(def ^:const ICON "https://dl.dropboxusercontent.com/u/14918307/slack_icon/eina.png")
(def ^:private out #(do (ja/out (apply str %&) :as NAME :icon-url ICON) nil))

(def ^:const MESSAGES
  {:open-pull-request


(defn eina-handler
  "エイナ(さん)?.+github.+テスト - github rss 取得のテスト"
  [{:keys [user] :as arg}]
  (jh/regexp arg
    #"エイナ(さん)?.+github.*テスト"
    (fn [& _]
      (out "@" user " はーい")
      (jb/set rss/RSS_URL nil)
      (->> (rss/get-github-feeds)
           (map rss/github-respond)
           (str/join "\n")
           pre
           out)

      (jb/set rss/RSS_URL nil)
      ((first github-schedule)))))
