Former-commit-id: 70f204681b
This commit is contained in:
Roman Volosovskyi 2016-06-27 15:12:53 +03:00
parent b1e8a6c30f
commit 4e25602eba
1 changed files with 21 additions and 21 deletions

View File

@ -46,10 +46,10 @@
(defn invoke-suggestions-handler! (defn invoke-suggestions-handler!
[{:keys [current-chat-id] :as db} _] [{:keys [current-chat-id] :as db} _]
(let [commands (get-in db [:chats current-chat-id :commands]) (let [{:keys [command content]} (get-in db [:chats current-chat-id :command-input])
{:keys [command content]} (get-in db [:chats current-chat-id :command-input]) {:keys [name type]} command
path [(if (commands command) :commands :responses) path [(if (= :command type) :commands :responses)
(:name command) name
:params :params
0 0
:suggestions] :suggestions]
@ -78,11 +78,11 @@
(assoc-in db [:chats current-chat-id :input-text] text)) (assoc-in db [:chats current-chat-id :input-text] text))
(defn invoke-command-preview! (defn invoke-command-preview!
[{:keys [current-chat-id staged-command] :as db} _] [{:keys [current-chat-id staged-command]} _]
(let [commands (get-in db [:chats current-chat-id :commands]) (let [{:keys [command content]} staged-command
{:keys [command content]} staged-command {:keys [name type]} command
path [(if (commands command) :commands :responses) path [(if (= :command type) :commands :responses)
(:name command) name
:preview] :preview]
params {:value content}] params {:value content}]
(j/call current-chat-id (j/call current-chat-id
@ -258,18 +258,18 @@
(dissoc new-command :rendered-preview)))) (dissoc new-command :rendered-preview))))
(defn invoke-commands-handlers! (defn invoke-commands-handlers!
[{:keys [new-commands current-chat-id] :as db}] [{:keys [new-commands current-chat-id]}]
(let [commands (get-in db [:chats current-chat-id :commands])]
(doseq [{:keys [content] :as com} new-commands] (doseq [{:keys [content] :as com} new-commands]
(let [{:keys [command content]} content (let [{:keys [command content]} content
path [(if (commands command) :commands :responses) type (:type command)
path [(if (= :command type) :commands :responses)
command command
:handler] :handler]
params {:value content}] params {:value content}]
(j/call current-chat-id (j/call current-chat-id
path path
params params
#(dispatch [:command-handler! com %])))))) #(dispatch [:command-handler! com %])))))
(defn handle-commands (defn handle-commands
[{:keys [new-commands]}] [{:keys [new-commands]}]