Skip to content
Snippets Groups Projects
Commit 69cd19e0 authored by Cam Saül's avatar Cam Saül Committed by GitHub
Browse files

Merge pull request #2773 from metabase/fix-overeager-metabot

Fix overeager metabot :robot:
parents d6605d22 94cd9b22
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
(put 'defannotation 'clojure-doc-string-elt 2)
(put 'defendpoint 'clojure-doc-string-elt 3)
(put 'defsetting 'clojure-doc-string-elt 2)
(put 'setting/defsetting 'clojure-doc-string-elt 2)
;; Define custom indentation for functions inside metabase.
;; This list isn't complete; add more forms as we come across them.
......
......@@ -85,7 +85,7 @@
(integer? card-id-or-name) (db/select-one ['Card :id :name], :id card-id-or-name)
(or (string? card-id-or-name)
(symbol? card-id-or-name)) (card-with-name card-id-or-name)
:else (throw (Exception. (format "I don't know what Card `%s` is. Give me a Card ID or name.")))))
:else (throw (Exception. (format "I don't know what Card `%s` is. Give me a Card ID or name." card-id-or-name)))))
(defn ^:metabot show
"Implementation of the `metabot show card <name-or-id>` command."
......@@ -141,14 +141,16 @@
(dispatch-fn "understand" :metabot))
(defn- eval-command-str [s]
;; if someone just typed "metabot" (no command) act like they typed "metabot help"
(let [s (if (seq s)
s
"help")]
(when-let [tokens (seq (edn/read-string (str "(" (-> s
(str/replace "“" "\"") ; replace smart quotes
(str/replace "”" "\"")) ")")))]
(apply apply-metabot-fn tokens))))
(when (string? s)
;; if someone just typed "metabot" (no command) act like they typed "metabot help"
(let [s (if (seq s)
s
"help")]
(log/debug "Evaluating Metabot command:" s)
(when-let [tokens (seq (edn/read-string (str "(" (-> s
(str/replace "“" "\"") ; replace smart quotes
(str/replace "”" "\"")) ")")))]
(apply apply-metabot-fn tokens)))))
;;; # ------------------------------------------------------------ Metabot Input Handling ------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment