Fix group commands

This commit is contained in:
janherich 2018-01-08 15:01:44 +01:00
parent c99af08c4f
commit d98f3846fd
No known key found for this signature in database
GPG Key ID: C23B473AFBE94D13
1 changed files with 23 additions and 20 deletions

View File

@ -245,7 +245,7 @@
metadata metadata
args] args]
:as content} :content :as content} :content
:keys [chat-id jail-id data-type event-after-creator message-id current-time]}] :keys [chat-id group-id jail-id data-type event-after-creator message-id current-time]}]
(let [{:keys [dapp? dapp-url name]} (get contacts chat-id) (let [{:keys [dapp? dapp-url name]} (get contacts chat-id)
metadata (merge metadata metadata (merge metadata
(when dapp? (when dapp?
@ -267,6 +267,7 @@
request-data {:message-id message-id request-data {:message-id message-id
:chat-id chat-id :chat-id chat-id
:group-id group-id
:jail-id (or owner-id jail-id) :jail-id (or owner-id jail-id)
:content {:command (:name command) :content {:command (:name command)
:scope-bitmask (:scope-bitmask command) :scope-bitmask (:scope-bitmask command)
@ -290,25 +291,27 @@
If it's normal command instead (determined by nil response to `:on-send` jail request), If it's normal command instead (determined by nil response to `:on-send` jail request),
processing continues by requesting command preview before actually sending the command processing continues by requesting command preview before actually sending the command
message." message."
[{:keys [current-chat-id] :as db} {{:keys [bot]} :command :as content} message-id current-time] [{:keys [current-chat-id chats] :as db} {{:keys [bot]} :command :as content} message-id current-time]
(let [params-template {:content content (let [params-template {:content content
:chat-id current-chat-id :chat-id current-chat-id
:jail-id (or bot current-chat-id) :group-id (when (get-in chats [current-chat-id :group-chat])
:message-id message-id current-chat-id)
:current-time current-time} :jail-id (or bot current-chat-id)
on-send-params (merge params-template :message-id message-id
{:data-type :on-send :current-time current-time}
:event-after-creator (fn [_ jail-response] on-send-params (merge params-template
[::check-command-type {:data-type :on-send
jail-response :event-after-creator (fn [_ jail-response]
params-template])}) [::check-command-type
after-validation-events [[::request-command-data on-send-params]] jail-response
validation-params (merge params-template params-template])})
{:data-type :validator after-validation-events [[::request-command-data on-send-params]]
:event-after-creator (fn [_ jail-response] validation-params (merge params-template
[::proceed-validation {:data-type :validator
jail-response :event-after-creator (fn [_ jail-response]
after-validation-events])})] [::proceed-validation
jail-response
after-validation-events])})]
(request-command-data db validation-params))) (request-command-data db validation-params)))
;;;; Handlers ;;;; Handlers