Handle command input call message
This commit is contained in:
parent
5e38d5589a
commit
c1dd4a9ab9
|
@ -17,7 +17,7 @@
|
||||||
set-chat-command-request]]
|
set-chat-command-request]]
|
||||||
[syng-im.handlers.server :as server]
|
[syng-im.handlers.server :as server]
|
||||||
[syng-im.handlers.contacts :as contacts-service]
|
[syng-im.handlers.contacts :as contacts-service]
|
||||||
|
[syng-im.handlers.suggestions :refer [get-command]]
|
||||||
[syng-im.handlers.sign-up :as sign-up-service]
|
[syng-im.handlers.sign-up :as sign-up-service]
|
||||||
|
|
||||||
[syng-im.models.chats :refer [create-chat]]
|
[syng-im.models.chats :refer [create-chat]]
|
||||||
|
@ -128,6 +128,8 @@
|
||||||
(register-handler :send-chat-msg
|
(register-handler :send-chat-msg
|
||||||
(fn [db [action chat-id text]]
|
(fn [db [action chat-id text]]
|
||||||
(log/debug action "chat-id" chat-id "text" text)
|
(log/debug action "chat-id" chat-id "text" text)
|
||||||
|
(if-let [command (get-command text)]
|
||||||
|
(dispatch [:set-chat-command (:command command)])
|
||||||
(let [msg (if (= chat-id "console")
|
(let [msg (if (= chat-id "console")
|
||||||
(sign-up-service/send-console-msg text)
|
(sign-up-service/send-console-msg text)
|
||||||
(let [{msg-id :msg-id
|
(let [{msg-id :msg-id
|
||||||
|
@ -141,7 +143,7 @@
|
||||||
:content-type text-content-type
|
:content-type text-content-type
|
||||||
:outgoing true}))]
|
:outgoing true}))]
|
||||||
(save-message chat-id msg)
|
(save-message chat-id msg)
|
||||||
(signal-chat-updated db chat-id))))
|
(signal-chat-updated db chat-id)))))
|
||||||
|
|
||||||
(register-handler :send-chat-command
|
(register-handler :send-chat-command
|
||||||
(fn [db [action chat-id command content]]
|
(fn [db [action chat-id command content]]
|
||||||
|
|
|
@ -11,3 +11,8 @@
|
||||||
;; TODO change 'commands' to 'suggestions'
|
;; TODO change 'commands' to 'suggestions'
|
||||||
(filterv #(.startsWith (:text %) text) commands)
|
(filterv #(.startsWith (:text %) text) commands)
|
||||||
[]))
|
[]))
|
||||||
|
|
||||||
|
(defn get-command [text]
|
||||||
|
(when (= (get text 0) "!")
|
||||||
|
;; TODO change 'commands' to 'suggestions'
|
||||||
|
(first (filter #(= (:text %) text) commands))))
|
||||||
|
|
Loading…
Reference in New Issue