diff --git a/src/morse/api.clj b/src/morse/api.clj index e50ce05..5512ec9 100644 --- a/src/morse/api.clj +++ b/src/morse/api.clj @@ -101,6 +101,18 @@ :form-params query})] (-> resp :body)))) +(defn edit-reply-markup + "Edits only the reply markup of message + (https://core.telegram.org/bots/api#editmessagereplymarkup)" + ([token chat-id message-id reply-markup] (edit-reply-markup token chat-id message-id {} reply-markup)) + ([token chat-id message-id options reply-markup] + (let [url (str base-url token "/editMessageReplyMarkup") + query (into {:chat_id chat-id :reply_markup reply-markup :message_id message-id} options) + resp (http/post url {:content-type :json + :as :json + :form-params query})] + (-> resp :body)))) + (defn delete-text "Removing a message from the chat" diff --git a/test/morse/api_test.clj b/test/morse/api_test.clj index 9369f8e..a1e0034 100644 --- a/test/morse/api_test.clj +++ b/test/morse/api_test.clj @@ -91,6 +91,19 @@ ; check that a nested option has encoded (is (u/has-subset? {:reply_markup {:keyboard [[{:text "button"}]]}} [body])))) +(deftest edit-reply-markup-request + (let [req (-> (api/edit-reply-markup token chat-id message-id {:keyboard [[{:text "button"}]]}) + (u/capture-request)) + body (json/decode (slurp (:body req)) true)] + + ; check that it is now post request + (is (= :post (:request-method req))) + + ; check that default params are presented + (is (u/has-subset? {:chat_id chat-id + :message_id message-id + :reply_markup {:keyboard [[{:text "button"}]]}} [body])))) + (deftest delete-text-request (let [req (-> (api/delete-text token chat-id message-id) (u/capture-request))